houssam_ballout Posted February 18, 2008 Share Posted February 18, 2008 hello all, I am trying this sql: select count(OptionNb),comments from tblanswer where idQuestion = $idQuestion And OptionNb = 'option$i' and I got this error Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause How could I solve it ? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/91654-sql-group-by-error/ Share on other sites More sharing options...
uniflare Posted February 18, 2008 Share Posted February 18, 2008 you may want to review: http://dev.mysql.com/doc/refman/5.0/en/counting-rows.html im not sure what exact reslults your trying to get and what your table structure is but you could try this: select count(OptionNb),comments from tblanswer where idQuestion = $idQuestion And OptionNb = 'option$i' GROUP BY `comments` Link to comment https://forums.phpfreaks.com/topic/91654-sql-group-by-error/#findComment-469478 Share on other sites More sharing options...
aschk Posted February 18, 2008 Share Posted February 18, 2008 I'm curious to know what information you're trying to get out of this. On 1st inspection I thought you were after the number of comments for a particular question, however I then realised you appear to be after something related to OptionNB. What is OptionNB? The query that uniflare has given you will count the number of options based on comment, where the question id is set and the OptionNB is set. Clarify what you're expecting from this query and i'm sure we can guide you in the right direction. Link to comment https://forums.phpfreaks.com/topic/91654-sql-group-by-error/#findComment-469487 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.