select A.* from A,B where A.c=B.c union all select B.* from A,B where B.c=A.c
select * from A,B where A.C=B.C
create table A ( id int, c varchar(20))create table B ( id int, c varchar(20))insert A select 1,'tom' union all select 3,'jack'insert B select 2,'terry' union all select 4,'jack'select a.* from a,b where a.c=b.c union all select b.* from a,b where a.c=b.c drop table a drop table b 结果 3 jack 4 jack
union all
select B.* from A,B where B.c=A.c
id int,
c varchar(20))create table B (
id int,
c varchar(20))insert A
select 1,'tom'
union all
select 3,'jack'insert B
select 2,'terry'
union all
select 4,'jack'select a.* from a,b where a.c=b.c
union all
select b.* from a,b where a.c=b.c
drop table a
drop table b
结果
3 jack
4 jack