Coding challenge Day-8

Coding challenge Day-8

Eighth day of I4G coding challenge

Combining two tables

Question

Today's task was to use an SQL query to combine two tables. Just seeing the question I went straight to watch a short introduction to SQL. This is because I had zero prior knowledge of SQL.

Thought process

After going through some videos on SQL queries, the question became straightforward to answer. Let's go on a journey through my thought process

  1. The first step was to note down the information that will be extracted from the two tables which were the first name and last name from the Person table and city, and state from the Address table. Also, note down the joining point.

  2. After getting this information, the next thing to figure out was the joining type. I had to pause and go make more research on the various joining types.

  3. After my research, I discovered the LEFT JOIN will be the perfect fit since I was to join the address table (right) to the person table(left) and will also have to return NULL where the values didn't match. All these matched the exact implementation that was intended.

Implementation

Moving on to implement my thought process, I attempted to use the INNER JOIN at first but didn't return NULL for the values that didn't match. This was actually what led me to make the initial research as described in my thought process.

After the research and I attempted with the LEFT JOIN, my code ran and passed(You can call me SQL guru now please😂😌).

What I learnt

It's obvious at this point to know what I learnt. I learnt about some basic concepts of SQL and whenever I come across SQL query again, I will know exactly how to navigate and know where to look for information

Conclusion

Result

As always, the task was an important one because I learnt new concepts.

My code had a runtime of 468ms

Day eight(8) done, two(2) more days to go!

You can follow me on Twitter