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
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 |
CodePudding user response:
You can use the union all
operator:
SELECT id, description
FROM table1
UNION ALL
SELECT id, material_name
FROM table2