I have 3 tables (simplified for example): entries: entry_id | cat_id | entry_date | entry_body categories: cat_id | cat_name | cat_level category_links: cat_id | entry_id I want to select entries ordered by their entry_date in DESC order, and also grab the category they appear in. They can appear in multiple categories, so I want to grab the one with the highest cat_level. How do I do this? Thanks!
my advise is to use sub query select t1.entry_id,(select t2.cat_id from categories as t2 left join entries as t1 on t1.cat_id = t2.cat_id order by cat_level desc limit 0) from entries as t1 left join categories from t2 on t1.cat_id = t2.cat_id try join the 2 tables first on respect to what you want. i hope it works..