Monday , 25 September 2023
Breaking News
Home > Tutorials > MySQL > How to Get Records From Multiple Tables and Show Into One Column

How to Get Records From Multiple Tables and Show Into One Column

Assalam-o-Alaikum!

Dear friends hope you will be fine. Today we will discuss on a problem which will make our work easy. Our some coding of PHP will reduce. Today we are going to learn a MySQL query technique in which you will fetch records from multiple tables and show in one column. So let’s start.

Problem:

Suppose you have three (3) tables ‘2017-12-26’, ‘2017-12-27’ and ‘2017-12-28’ and you need all the data in these tables with WHERE match and then show it into one column, I mean in one list.

Solution:

You need to use UNION technique of MySQL.

How:

Here is table structure

 

As you can see we have three tables and some data in it. Now we want all records that’s id=1 from all of these tables and then show it into one column or in list. Here we will use UNION method between three tables like this

Now run the command so you will see this three records. Their ID will be 1 but values are different because these are not from one table. Hope you understand.

See you in next tutorial.

 

About Muhammad Faryad

Muhammad Faryad is a professional web application developer. He has been working for 5 years in ICE786 Technologies Pvt. Ltd as a Senior Programmer and Developer. You can contact him on facebook at www.facebook.com/tolamangali

Leave a Reply

Ad Test

%d bloggers like this: