postgresqlHow do I use PostgreSQL's UNION ALL statement?
The PostgreSQL UNION ALL statement is used to combine the result sets of two or more SELECT statements into a single result set. It does not remove duplicate rows from the result set, unlike the UNION statement.
Example code
SELECT * FROM table1
UNION ALL
SELECT * FROM table2;
The example code above will combine the results from both table1 and table2 into a single result set.
Code explanation
- SELECT: specifies the columns to be returned by the query
- FROM: specifies the table(s) from which to retrieve the data
- UNION ALL: combines the result sets of two or more SELECT statements into a single result set
Helpful links
More of Postgresql
- How do I parse XML data using PostgreSQL?
- How can Zalando use PostgreSQL to improve its software development?
- How do I use PostgreSQL ZonedDateTime to store date and time information?
- How can I troubleshoot zero damaged pages in PostgreSQL?
- How can I use PostgreSQL and ZFS snapshots together?
- How do I use PostgreSQL's XMIN and XMAX features?
- How can I use PostgreSQL's "zero if null" feature?
- How do I use PostgreSQL and ZFS together?
- How do I use PostgreSQL's XMLTABLE to parse XML data?
- How can I use PostgreSQL with YAML?
See more codes...