nathanblogs Posted November 26, 2007 Share Posted November 26, 2007 hey, I am trying to make a SQL statement that will allow me to select only group members that appear multiple times in a table. This is my current sql statement: SELECT *, count(grpmem_peopleid) AS num FROM group_members WHERE num > 1 GROUP BY grpmem_peopleid ORDER BY num DESC my current error is this: Unknown column 'num' in 'where clause' Quote Link to comment https://forums.phpfreaks.com/topic/78883-solved-count-with-a-where-clause/ Share on other sites More sharing options...
rajivgonsalves Posted November 26, 2007 Share Posted November 26, 2007 try this statment instead SELECT count(grpmem_peopleid) AS num ,* FROM group_members GROUP BY grpmem_peopleid having count(*) > 1 ORDER BY num DESC Quote Link to comment https://forums.phpfreaks.com/topic/78883-solved-count-with-a-where-clause/#findComment-399254 Share on other sites More sharing options...
nathanblogs Posted November 26, 2007 Author Share Posted November 26, 2007 Works a charm thanks Quote Link to comment https://forums.phpfreaks.com/topic/78883-solved-count-with-a-where-clause/#findComment-399256 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.