postgresqlHow do I perform a left join in PostgreSQL?
A left join in PostgreSQL is used to combine two tables by matching values from the left table with values from the right table. It returns all rows from the left table, even if there are no matches in the right table.
The syntax for a left join in PostgreSQL is as follows:
SELECT *
FROM table_1
LEFT JOIN table_2
ON table_1.column_1 = table_2.column_1
This example code will return all rows from table_1 and any matching rows from table_2.
The parts of the code are:
SELECT *
: This selects all columns from the tables.FROM table_1
: This specifies the left table.LEFT JOIN table_2
: This specifies the type of join to use.ON table_1.column_1 = table_2.column_1
: This specifies the join condition.
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...