Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Combine 2 tables in mysql with different column names in MySQL

I want to combine two tables in one query and don’t know how to do it, for example:

Table 1

id description
1 description_1
2 description_2
3 description_3
4 description_4

Table 2

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

id material_name
5 material_name_1
6 material_name_2
7 material_name_3
8 material_name_4

ultimately the result of my query should look like this:

id description
1 description_1
2 description_2
3 description_3
4 description_4
5 material_name_1
6 material_name_2
7 material_name_3
8 material_name_4

>Solution :

You can use the union all operator:

SELECT id, description
FROM   table1
UNION ALL
SELECT id, material_name
FROM   table2
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading