SELECT A.name, CASE WHEN B.name IS NOT NULL THEN 'common' ELSE 'not common' END FROM table1 A LEFT JOIN table2 B ON A.name = B.name