How to compare two tables in postgres
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want compare two column values which come from two different queries. Can anyone suggest a query which compares two columns in Postgres? 回答1: Well, the easiest to understand--but not necessarily the fastest--is probably something like this. (But you might mean something else by "compare".) -- Values in column1 that aren't in column2. SELECT column1 FROM query1 WHERE column1 NOT IN (SELECT column2 FROM query2); -- Values in column2 that aren't in column1. SELECT column2 FROM query2 WHERE column2 NOT IN (SELECT column1 FROM query1); --