DEV Community 👩‍💻👨‍💻

Ezekiel nwuguru
Ezekiel nwuguru

Posted on

DAY 08: Combine two tables

Hey! it's day 8 of 10 days coding challenge with I4G. Today's task was to write an SQL code to combine two tables.

Thought process:

  • Understanding of problem: The task here requires combine two tables in an SQL. The first table Person contains the first and last name while the second table contains the address of the person. So, it is required that the two tables be combined such that a single table with the person's name and address is obtained.
  • Solution: To be able to access a single person's data in both table, a personal id assigned to each table must be the same. To fetch the detail, we simply select the names from the first table and use LEFT JOIN to combine it with the address in the second table where both personal id is the same. If no matching details is found a null is returned.


  • Select first and last name from the Person table
  • Select city and state from the Address table
  • Condition: personal id in both table must be same
  • use left join to combine the address with the names

Checkout the full code here: Combine Two Tables - LeetCode

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.