desithugg Posted August 13, 2006 Share Posted August 13, 2006 [code]$query = "SELECT forums.pic,forums.name,forums.des,forums.poster,forums.timer,forums.id,threads.fid FROM forums left join threads on threads.fid = forums.id where category = 'general' ORDER BY ors ASC";$result = mysql_query($query) or die(mysql_error());[/code]on the threads table i want to count how many threads are there that have the threads.fid = forums.iddo i use count i have tried count(threads.fid) and threads,count(fid) but didnt work. any other ideas? Link to comment https://forums.phpfreaks.com/topic/17425-join-query-count/ Share on other sites More sharing options...
Barand Posted August 13, 2006 Share Posted August 13, 2006 try[code]$query = "SELECT forums.pic,forums.name,forums.des,forums.poster, forums.timer,forums.id, COUNT(threads.fid) as threadcount FROM forums left join threads on threads.fid = forums.id where category = 'general' ORDER BY ors ASC";[/code] Link to comment https://forums.phpfreaks.com/topic/17425-join-query-count/#findComment-74169 Share on other sites More sharing options...
desithugg Posted August 13, 2006 Author Share Posted August 13, 2006 i ahve tried that barand but i get this errorMixing 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/17425-join-query-count/#findComment-74171 Share on other sites More sharing options...
Barand Posted August 13, 2006 Share Posted August 13, 2006 Oops[code]$query = "SELECT forums.pic,forums.name,forums.des,forums.poster, forums.timer,forums.id, COUNT(threads.fid) as threadcount FROM forums left join threads on threads.fid = forums.id where category = 'general' GROUP BY forums.id ORDER BY ors ASC";[/code] Link to comment https://forums.phpfreaks.com/topic/17425-join-query-count/#findComment-74173 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.