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 Quote 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'; Quote 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 Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/156441-solved-query-help/#findComment-823737 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.