UNION UNION ALL//Table Attribute Create table student( id int unsigned not null auto_increment, name varchar(20) not null, primary ...
UNION
UNION ALL
//Table Attribute
Create table student(
id int unsigned not null auto_increment,
name varchar(20) not null,
primary key(id)
)ENGINE=InnoDb AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ;
Create table student1(
id int unsigned not null auto_increment,
name varchar(20) not null,
primary key(id)
)ENGINE=InnoDb AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ;
select id name from student
UNION ALL
select 0,name from student1
Output:
1 小明
2 Jack --->student
0 Tom --->student1
0 Jack --->student
select id name from student
UNION ALL
select id,name from student1
Output:
1 小明
2 Jack --->student
1 Tom --->student1
2 Jack --->student
select id name from student
UNION ----<UNION>----
select id,name from student1
Output:
1 小明
2 Jack --->student
1 Tom --->student1
Jack is missing...............
原标题:两表合并查询
关键词:
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。