PDA

View Full Version : SQL Query for blogs question


Warlord
01-15-2011, 08:36 PM
I'm trying to query the sql database to only retrieve blogs that match a certain category but I can't figure out what the syntax is for categories.

I'm modifying an existing query that looks like this:


SELECT blogid, blog.title, blog_user.title AS blogname, comments_visible, username, dateline, userid, views

FROM " . TABLE_PREFIX . "blog AS blog

LEFT JOIN " . TABLE_PREFIX . "blog_user AS blog_user ON blog_user.bloguserid=blog.userid

WHERE blog.state='visible' and blog.pending=0 and blog_user.options_guest=3

ORDER BY dateline DESC

LIMIT 5


I've tried adding and blog.cat='Project Fanboy Columns' and other variations but none of them seem to be correct. Can anyone tell me what blog.cat should really be?

--------------- Added 1295136492 at 1295136492 ---------------

Nevermind, I figured it out.

For anyone who's interested, it's blog.categories, which I could've sworn I had tried before but I guess not.

Also, you have to input the category ID, not the actual name of the category (string). So it looks like this:

blog.categories='10'

instead of

blog.categories='Project Fanboy Columns'