select * from mytable where id in (select id from table2)