💻Accepted 99%✅ || 🟡SQLite / MySQL💯 || Combine Two Tables 🔊
\uD83D\uDD25Combine Two Tables\uD83D\uDD25\n> ### To solve this problem using SQL, we can use a LEFT JOIN to combine the Person and Address tables based on the 
# \uD83D\uDD25Combine Two Tables\uD83D\uDD25\n> ### To solve this problem using SQL, we can use a `LEFT JOIN` to combine the Person and Address tables based on the personId column. This will give us all the records from the `Person` table, along with any matching records from the `Address` table. If there is no matching record in the `Address` table, the columns from the `Address` table will be `NULL`.\n\n```\n/* Write your T-SQL query statement below */\nSELECT FirstName, LastName, City, State\nFROM Person\nLEFT JOIN Address\nON Person.PersonID = Address.PersonID;\n```\n## Explanation:\n- 1. The `SELECT` statement is used to specify the columns we want to retrieve from the tables.\n- 2. We are selecting the `firstName`and `lastName` columns from the `Person` table, and the city and state columns from the `Address` table.\n- 3. The `FROM` clause specifies the tables we are retrieving data from. In this case, we are using the `Person` table.\n- 4. The `LEFT JOIN` keywords are used to combine the `Person` and `Address` tables based on the `personId` column. This will include all records from the `Person` table, along with any matching records from the `Address` table.\n- 5. The `ON` keyword is used to specify the condition for the join. We want to join records where the `personId` column in the `Person` table matches the personId column in the `Address` table.\n- 6. The result of the query will contain the `firstName` and `lastName` of each person, along with the city and state from the `Address` table. If there is no matching record in the `Address` table, the city and state columns will be `NULL`.\n![7abc56.jpg](https://assets.leetcode.com/users/images/ef43f6d8-5f6b-41b1-a559-feca41b33c12_1698443602.6721394.jpeg)\n## Thanks bro\u2705 :)\n
['MySQL', 'MS SQL Server']