SELECT table1.* FROM table1 INNER JOIN table2 ON (table1.category=table2.id) WHERE table1.category = 1 OR table2.parent_id = 1