SELECT * FROM table1 INNER JOIN table2 ON table2.empid = table1.empid AND table2.alt_id <> table1.alt_id