I assume that this query runs OK and gives no errors... The second part of the query is what has me a bit puzzled, specially this part
Code:
$cat_q games.verified = 1
I don't know what that variable $cat_q, is doing there, all by itself. No comparisions of any kind or anything. Although I confess that I always follow the same approach with my SQL and I try to keep it simpler than simple.
Also, I'm surprised that you don't use a join (although in this case, it makes no difference). Adding conditions in the WHERE area to create the join is old school but completely valid.
I'm also assuming that your real SQL query is not using wild cards. Queries run faster if you don't use wild cards.
So I wonder if the query wouldn't be more efficient if it was something like this
Code:
SELECT g.field1, g.field2..., c.field1, c.field2.... FROM (games g JOIN categories c ON c.category_id = g.category_id) WHERE g.verified = 1 AND g.added_date <= '2012/03/01' ORDER BY file_id DESC LIMIT 4;
I removed the $cat_q as I didn't know which condition you wanted to add with it
Edit: The use of alias (c for categories and g for games) is because I often get bored of writing the whole table name more than once
Bookmarks