Re: How to compare two tables in PostgreSQL
От | Igor Neyman |
---|---|
Тема | Re: How to compare two tables in PostgreSQL |
Дата | |
Msg-id | A76B25F2823E954C9E45E32FA49D70EC08EEEC02@mail.corp.perceptron.com обсуждение исходный текст |
Ответ на | How to compare two tables in PostgreSQL (saikiran mothe <saikiran.mothe@gmail.com>) |
Ответы |
Re: How to compare two tables in PostgreSQL
|
Список | pgsql-sql |
From: saikiran mothe [mailto:saikiran.mothe@gmail.com] Sent: Saturday, November 10, 2012 10:14 PM To: pgsql-sql@postgresql.org Subject: How to compare two tables in PostgreSQL Hi, How can i compare two tables in PostgreSQL. Thanks, Sai Here is simple sql to show data in table1, but not in table2: SELECT <common_column_list> from table1 EXCEPT SELECT <common_column_list> from table2; And this sql shows data in table2 but not in table1: SELECT <common_column_list> from table2 EXCEPT SELECT <common_column_list> from table1; Or, you could combine them in one statement, adding "indicator" column: SELECT <common_column_list>, 'not in table2' as indicator from table1 EXCEPT SELECT <common_column_list>, 'not in table2' as indicator from table2 UNION SELECT <common_column_list>, 'not in table1' as indicator from table2 EXCEPT SELECT <common_column_list>, 'not in table1' as indicator from table1; Regards, Igor Neyman
В списке pgsql-sql по дате отправления: