Thursday, October 14, 2021

Comparing two Postgresql tables

To find differences between two tables with the same columns, use the EXCEPT keyword. This can be extended to as many columns as are in the tables.

SELECT id, employee_id, effective_on, 'not in table2' AS note FROM table1 EXCEPT SELECT id, employee_id, effective_on, 'not in table2' AS note FROM table2;

No comments:

Post a Comment