ballouta Posted May 1, 2009 Share Posted May 1, 2009 Hello i have this query: SELECT * FROM `links` where `event` ='smthg' i tried to get a count value in the same query but it was wrong: SELECT COUNT(*) AS MD, * FROM `links` where `event` ='smthg' what is the correct query? Thank you Link to comment https://forums.phpfreaks.com/topic/156441-solved-query-help/ Share on other sites More sharing options...
Ken2k7 Posted May 1, 2009 Share Posted May 1, 2009 SELECT *, COUNT(*) AS `MD` FROM `links` WHERE `event` = 'smthg'; Link to comment https://forums.phpfreaks.com/topic/156441-solved-query-help/#findComment-823722 Share on other sites More sharing options...
ballouta Posted May 1, 2009 Author Share Posted May 1, 2009 I got this error: #1140 - Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause Link to comment https://forums.phpfreaks.com/topic/156441-solved-query-help/#findComment-823725 Share on other sites More sharing options...
ballouta Posted May 1, 2009 Author Share Posted May 1, 2009 thanks I googled for the error I got and i have to add group by: http://dev.mysql.com/doc/refman/5.1/en/counting-rows.html Link to comment https://forums.phpfreaks.com/topic/156441-solved-query-help/#findComment-823737 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.