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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.