Jump to content

Problem inserting a WHERE syntax in my mySQL string


Johns3n

Recommended Posts

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

Solved it myself after much trial and error :P

 

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 :P

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.