Get the App
SLTechnology News&Howtos  ›  Database  › 

The use of left join keyword in mysql

Shulou Source: shulou.com Published: 2022-06-01 15:00:10 09月30日 Update

This article is to share with you about the use of the left join keyword in mysql, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Left join keyword

The LEFT JOIN keyword returns all rows from the left table (table_name1), even if there are no matching rows in the right table (table_name2).

LEFT JOIN keyword syntax

SELECT column_name (s) FROM table_name1 LEFT JOIN table_name2 ON table_name1.column_name=table_name2.column_name

Note: in some databases, LEFT JOIN is called LEFT OUTER JOIN.

Let's look at a picture:

Note: the LEFT JOIN keyword returns all rows from the left table, even if there is no match in the right table (access_log).

Example:

SELECT Persons.LastName, Persons.FirstName, Orders.OrderNoFROM PersonsLEFT JOIN OrdersON Persons.Id_P=Orders.Id_PORDER BY Persons.LastName and above are the use of the left join keyword in mysql. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: Keywords more knowledge articles practical examples that is work meetings data databases articles look knowledge points industries details grammar information information channels follow Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Redmi vpn macOS MariaDB