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 can I set a PostgreSQL interval to zero?
- How can I use PostgreSQL XOR to compare two values?
- How can I troubleshoot zero damaged pages in PostgreSQL?
- How do I use PostgreSQL ZonedDateTime to store date and time information?
- How can I use PostgreSQL for my project?
- How can I use PostgreSQL with YAML?
- How can I use PostgreSQL XML functions to manipulate XML data?
- How do I use PostgreSQL's XMLTABLE to parse XML data?
See more codes...