Is it possible to join two tables in mysql into one single table , both tables have the same column names ...?
table a has
id name state
1 jose up
2 sam mp
3 jack tn
table b is
id name state
4 ken ker
5 sk wb
is it possible to join both like:
id name state
1 jose up
2 sam mp
3 jack tn
4 ken ker
5 sk wb
Use UNION ALL
SELECT
id,name,state
from
tbla
UNION ALL
SELECT
id,name,state
from
tblb
If you want the exact duplicates to be excluded from the output. Use UNION
SELECT
id,name,state
from
tbla
UNION
SELECT
id,name,state
from
tblb
Reference:
The requirement you are describing is a union all
query, not a join
:
SELECT id, name, state
FROM table_a
UNION ALL
SELECT id, name, state
FROM table_b
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.