PostgreSQL Set Operators

operator to combine result sets of multiple queries into a single result sets.

  • union
  • union all
  • intersect
  • except

Union Examples:

pearl=# select id from siva union select id from muthu;

Union all Examples:

pearl=# select id from siva union all select id from muthu;

Intersect Examples:

pearl=# select id from siva intersect select id from muthu;

Except Examples:

pearl=# select id from siva except select id from muthu;
pearl=# select id from muthu except select id from siva;


Comments