SELECT name, 'In table2!' FROM table1 WHERE ID IN (SELECT ID FROM table2) JOIN SELECT name, 'Not in table2!' FROM table1 WHERE NOT ID IN (SELECT ID FROM table2);