1

Topic: Db query question

Just wondering if it's possible to adapt this query to grab the category in which the forum resides, without doing a second query separately?

$db->query('SELECT forum_id FROM '.$db->prefix.'topics WHERE id='.$topic_id)

Cheers,

Matt

Re: Db query question

Yes, join the forums table and get the category ID

3

Re: Db query question

I didn't think it was humanly possible to post a reply that fast. big_smile Cheers. smile

4

Re: Db query question

Is this correct?

SELECT t.forum_id, f.cat_id, c.cat_name FROM punbb_topics AS t LEFT JOIN punbb_forums AS f ON f.id=t.forum_id LEFT JOIN punbb_categories AS c ON c.id=f.cat_id WHERE t.id=1;

My db skills are not exactly great, btw. big_smile



Thanks again,

Matt

Re: Db query question

Looks fine to me

6

Re: Db query question

Cheers. smile