2 Ways to write the same query using LEFT JOIN. Easy explanation
Explanation:\nThe questuion asks us to report the first name, last name, city, and state of each person in the Person table. If the address of a personId is not
### **Explanation:**\nThe questuion asks us to report the first name, last name, city, and state of each person in the Person table. If the address of a personId is not present in the Address table, report null instead.\n\nLEFT JOIN works here since it exactly does the same. It returns all the records from the 1st table and the corresponding information from the 2nd table. If there\'s no matching data in the 2nd table, it returns NULL for those fields.\n\nNow the same query can be written in 2 ways. Here they are :\n\n#### **1st way (table1 LEFT JOIN table2 ON condition)**\n```\nSELECT P.firstName, P.lastName, A.city, A.state\nFROM Person P LEFT JOIN Address A\non P.personId = A.personId\n```\n\n#### **2nd way (table1 LEFT JOIN table2 USING column_name)**\n```\nSELECT P.firstName, P.lastName, A.city, A.state\nFROM Person P\nLEFT JOIN Address A USING (personId)\n```\n\nIf it helped or you learned a new way, kindly upvote. Thanks :)
['MySQL']