you are going to want to use a join. select * from table1 left join table2 on id.table1 = id.table2