left join on

Original link: https: //www.w3school.com.cn/sql/sql_join_left.asp

Left connecting (LEFT JOIN) Example

Now we want to list all of them, and their orders - if any.

You can use the following SELECT statement:

SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
FROM Persons
LEFT JOIN Orders
ON Persons.Id_P=Orders.Id_P
ORDER BY Persons.LastName

The results set:

LastName FirstName OrderNo
Adams John 22456
Adams John 24562
Carter Thomas 77895
Carter Thomas 44678
Bush George  

LEFT JOIN keyword from the left table (Persons) where all rows are returned, even in the right table (Orders) no matching rows.

Guess you like

Origin www.cnblogs.com/xudj/p/11535621.html