文章

顯示包含「USING」標籤的文章

SQL - Left Join

Use all the result form left side even that are null at the second table. Will return null when can t find result in right table. SELECT p.firstName , p.lastName, a.city , a.state FROM Person p LEFT JOIN Address a ON p.personId = a.personId; //USING(persionId) < Also OK Input: Person table: +----------+----------+-----------+ | personId | lastName | firstName | +----------+----------+-----------+ | 1 | Wang | Allen | | 2 | Alice | Bob | +----------+----------+-----------+ Address table: +-----------+----------+---------------+------------+ | addressId | personId | city | state | +-----------+----------+---------------+------------+ | 1 | 2 | New York City | New York | | 2 | 3 | Leetcode | California | +-----------+----------+---------------+------------+ Output: +-----------+----------+---------------+----------+ | firstName | lastName | city | state | +-----------+----------+-------...