mysql - SELECTING columns and matching rows -
got small problem regarding selecting data in mysql table. got 2 tables.
questions_table - id - name results_table - id - form_id - answer 1 - etc.
now want select forms has results, , form_id matches form id, because how linked.
i got this:
select f.id, f.name, count(res.id) forms f left join results res on f.id = res.form_id
but problem is, 1 row out of it, while have multiple forms multiple results, selects 1 form.
what doing wrong? left join statement?
aggregate function without group by
returns 1 row. need add group by
select f.id, f.name, count(res.id) forms f left join results res on f.id = res.form_id group f.id
Comments
Post a Comment