Nested mysql select statements

Posted by Jimmy Kamau on Stack Overflow See other posts from Stack Overflow or by Jimmy Kamau
Published on 2013-10-22T15:45:52Z Indexed on 2013/10/22 15:53 UTC
Read the original article Hit count: 257

I have a query as below:

$sult = mysql_query("select * from stories where `categ` = 'businessnews' and `stryid`='".mysql_query("SELECT * FROM comments WHERE `comto`='".mysql_query("select * from stories where `categ` ='businessnews'")." ORDER BY COUNT(comto) DESC")."'  LIMIT 3") or die(mysql_error());
                while($ow=mysql_fetch_array($sult)){

The code above should return the top 3 'stories' with the most comments {count(comto)}. The comments are stored in a different table from the stories. The code above does not return any values and doesn't show any errors. Could someone please help?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about sql