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' 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 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 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
Archived
This topic is now archived and is closed to further replies.