Forum Moderators: coopster
Original:
$query=mysql_query("SELECT * FROM news, publisher WHERE news.pub_hash=publisher.pubhash ORDER BY news.pubdate DESC LIMIT 40");
Where I'm at right now (Not working):
$query=mysql_query("SELECT * FROM publisher, localnews AS (SELECT * FROM news ORDER BY pubdate DESC LIMIT 40) WHERE localnews.pub_hash=publisher.pubhash ORDER BY localnews.pubdate DESC LIMIT 40");
I'm thinking my query was crashing the server because it had to first match up all of the publisher table with the news table, then select the 40 most recent. What I'm trying to accomplish in my rewrite is to get the 40 most recent files from the news table, then match only those entries with the publisher table.
Any help is very, very, very greatly appreciated!
SELECT * FROM publisher, (SELECT * FROM news ORDER BY pubdate DESC LIMIT 40) AS localnews WHERE localnews.pub_hash=publisher.pubhash ORDER BY localnews.pubdate DESC LIMIT 40
Added: It can be really helpful to test your queries by running them through phpMyAdmin (or something similar) because those tools will often spit out descriptive errors.