mysql - sql select with count condition -


i have 2 tables in db, first table called "questions" , hold questions id, second table called "answers" , hold answers questions (as multiple choices).

how select questions have less 4 answers?

questions table:

id     question 1      ...? 2      how many ...? 3      ....? 

answers table

id     question_id     answer 1          1             54 2          1             11 3          1             22 4          2            england 5          1              5 6          2            turkey 

how select questions have answers less 4?

thanks,

select questions.id, questions.question questions  inner join answers on questions.id = answers.question_id group questions.id, questions.question having count(questions.id) <4 

here go.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -