将原有四张表格合并为一张表格
将表格1与表格2进行合并
create table table1(
ID1 BIGINT(50)PRIMARY KEY,
NAME1 varchar(50),
PSW1 varchar(50)
);
CREATE TABLE TABLE2 (
ID2 BIGINT(50) PRIMARY KEY,
NAME2 varchar(50),
PSW2 varchar(50)
);
INSERT INTO
TABLE1(ID1, NAME1 ,PSW1)
VALUES(1,‘user1’,‘psw1’);
INSERT INTO
TABLE2(ID2, NAME2 ,PSW2)
VALUES(2,‘user2’,‘psw2’);
SELECT T1.ID1 ID_FIELD, T1.NAME1 NAME_FIELD, T1.PSW1 PSW_FIELD FROM TABLE1 T1
UNION
SELECT T2.ID2 ID_FIELD, T2.NAME2 NAME_FIELD, T2.PSW2 PSW_FIELD FROM TABLE2 T2;
在MYSQL下合并表格,并完成查询
最新推荐文章于 2023-07-13 13:33:36 发布