Postgres Intersect
Today I got to see some great SQL debugging that included the use of intersect
to compare two datasets.
intersect
computes the set intersection of the rows returned by the involved select
statements.
Here's a simple implementation:
dev=# select generate_series(1,1000) intersect
select generate_series(10,15);
generate_series
-----------------
11
12
10
15
13
14
Like a lot of things in Postgres, the order seems deterministic, but not predictable.
Tweet