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's XMLTABLE to parse XML data?
- How do I use PostgreSQL's XMIN and XMAX features?
- How can I troubleshoot zero damaged pages in PostgreSQL?
- How can I use PostgreSQL and ZFS snapshots together?
- How can I set a PostgreSQL interval to zero?
- How can I use PostgreSQL's "zero if null" feature?
- How do I use PostgreSQL ZonedDateTime to store date and time information?
- How can I monitor PostgreSQL performance using Zabbix?
- How can I use PostgreSQL with Zabbix?
- How can I use PostgreSQL for my project?
See more codes...