postgresqlHow do I use the PostgreSQL EXCEPT operator?
The PostgreSQL EXCEPT operator is used to compare the results of two SELECT statements and return any rows that are present in the first SELECT statement but not in the second SELECT statement. It is the equivalent of the MINUS operator in other database systems.
For example, the following code will return all rows from the ‘employee’ table that are not present in the ‘department’ table:
SELECT *
FROM employee
EXCEPT
SELECT *
FROM department;
The output of this query will depend on the data in the two tables.
Code explanation
- SELECT *: this is the command to select all columns from the table
- FROM employee: this specifies the table to select from
- EXCEPT: this is the EXCEPT operator
- SELECT *: this is the command to select all columns from the table
- FROM department: this specifies the table to select from
Helpful links
More of Postgresql
- How do I use PostgreSQL ZonedDateTime to store date and time information?
- How can Zalando use PostgreSQL to improve its software development?
- How can I use PostgreSQL with Zabbix?
- How do I use PostgreSQL's XMLTABLE to parse XML data?
- How can I use PostgreSQL and ZFS snapshots together?
- How can I use PostgreSQL with YAML?
- How do I parse XML data using PostgreSQL?
- How do I store an array in a PostgreSQL database?
- How can I troubleshoot zero damaged pages in PostgreSQL?
- How do I use PostgreSQL's XMIN and XMAX features?
See more codes...