How to Join Two Tables and Print Data From Both Tables in Single Table in SQL?

I was given a task to fetch data from multiple tables and bring them to a single table so that it can be used for wider requirement. Let me give some background of the data source and the structure of data so that you can give a correct solution to it.

My office has a very wider database which is consisting of more than 200 tables in it. So, there is one primary key which is called “Code” the field name which is common in all the tables and rest all data are uncommon in all the tables.

For example:

Table 1 contains field names  “code, name, supplier, location,”

Table 2 contains field names “code, country, price, Weight, language”

Table 3 contains field names “code, mfd, expiry, batch, received”

Now I am tasked to print the fields in single table like “code, name, mfd, expiry, location, weight, price”

I have tried to do it by the “join” command but there I am unable to do it with that function. There I am able to fetch data from two table only. That also I am getting some error while fetching multiple data.

Anyhow, I have done it with the help of “MS Access” after fetching data from tables in multiple layers.

But, I want to do it in one action and want to know that exact command line/script to fetch data from multiple tables based on primary key.

Also Read  Not at Hogwarts? You can still build and use a wand thanks to Kano

Leave a Comment