Jason Mayo Jason Mayo - 1 year ago 65
MySQL Question

mySQL Query over multiple tables

Help needed please! I need to grab the entry_id’s relating to cat_id of ’42’, then find all cat_id’s that are attached to the entry_id’s we have just filtered by. I then need to get the cat_group_id of them cat_id’s. See screenshots of tables below:

enter image description here

enter image description here


E.g. entry_id 92 has cat_id 42 assigned to it. But it also has 48 & 71. It's these numbers I need to output. But only if the entry_id is in cat_id 42

Answer Source

I didn't understand very well what you wanted, is it this?

inner join
  on exp_category_posts.cat_id = exp_categories.cat_id
  entry_id in (select entry_id from exp_category_posts where cat_id = 42)

Note: I didn't create the tables to test it, but I think the query is ok

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download