Johns3n Posted February 26, 2010 Share Posted February 26, 2010 Hello PHPFreaks This is really a straight forward question, which i am sure that you can solve in no time? I have this MySQL string: SELECT lork_posts.*, COUNT(post_id) as `commentCount` FROM lork_posts Left Join lork_comments ON lork_posts.id = post_id GROUP BY lork_posts.id ORDER BY lork_posts.id DESC But i need to modify it a little, because i made a new table row called is_frontpage, so i am thinking that i need WHERE syntax somewhere? This is the string i wrote: WHERE lork_posts.is_frontpage = Yes I tried messing around with in Phpmyadmin but was unable to come up with a working string But i hope you guys can help, as i can't help think it must be a straight forward thing xD Quote Link to comment https://forums.phpfreaks.com/topic/193421-problem-inserting-a-where-syntax-in-my-mysql-string/ Share on other sites More sharing options...
Johns3n Posted February 26, 2010 Author Share Posted February 26, 2010 Solved it myself after much trial and error it was the "yes" in my tables that were causing it to malfunction.. if i simply use 0 as No and 1 as Yes instead of text.. the problem is solved SELECT ".$tbl_name.".*, COUNT(post_id) as `commentCount` FROM ".$tbl_name." LEFT JOIN ".$db_prefix."comments ON ".$tbl_name.".id = post_id WHERE ".$tbl_name.".is_frontpage = 1 GROUP BY ".$tbl_name.".id ORDER BY ".$tbl_name.".id DESC Quote Link to comment https://forums.phpfreaks.com/topic/193421-problem-inserting-a-where-syntax-in-my-mysql-string/#findComment-1018466 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.