Topic: query optimization
Hey, does anybody have an idea how to combine the following two queries?
QUERY 1
$result = $db->query("SELECT p.id, p.poster, p.poster_id, p.message, p.topic_id, p.first_post, t.subject, t.forum_id FROM ".$db->prefix."posts AS p INNER JOIN ".$db->prefix."topics AS t ON t.id=p.topic_id WHERE p.deleted=1 ORDER BY p.posted DESC LIMIT ".$p.", 10");
$deleted_post = $db->fetch_assoc($result);
QUERY 2
$inner = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE first_post=1 AND topic_id='.$deleted_post['topic_id'].' AND id!='.$deleted_post['id']);
My problem is that the second query is run for every single row that the first query fetches. Anybody have an idea how to fix that?
FluxBB - v1.4.8