Forum Moderators: coopster
SELECT topic_id, topic_title, topic_poster, topic_type, topic_status, username, topic_replies, topic_views, bb_topics.forum_id, forum_name, post_text FROM bb_topics, bb_users, bb_posts_text, bb_forums WHERE topic_status!='2' and topic_type!='2' and bb_topics.forum_id!='640' and bb_topics.topic_poster=bb_users.user_id and bb_topics.forum_id= bb_forums.forum_id and bb_posts_text.post_id=bb_topics.topic_first_post_id ORDER BY topic_type DESC, topic_id DESC LIMIT 20";
topic_status
topic_type
bb_topics.forum_id
bb_topics.topic_poster
bb_topics.forum_id
bb_posts_text.post_id
bb_users.user_id
bb_forums.forum_id
bb_topics.topic_first_post_id
and possibly the topic_id field as well, since it is in one of the ORDER BY parameters. Additional indexes will increase the size of the database, but will make searching faster.
SELECT attr_1, attr_2, attr_3...
FROM tbl_1 NATURAL JOIN tbl_2
- and it will have the same effect as if you used the 'from' and 'where' clauses as above. I think this is only really useful for one of your comparisons as the others have differing key names but it does make it a bit more manageable.
I seem to remember there are custom joins as well that allow you to specify the attributes to join on but the syntax eludes me...