select x.*.y.* from (select a,b from t) x,(select a,b from t2)y
按照上面的写法,当y表中无记录x表中有记录 或 y表中有记录x表中无记录时,整个语句不返回值,也就是说只要其中一个表无记录整个语句就不返回值。现在的想只要x表或y表其中任何表存在记录时,就要显示字段出来,语句该怎么写?
按照上面的写法,当y表中无记录x表中有记录 或 y表中有记录x表中无记录时,整个语句不返回值,也就是说只要其中一个表无记录整个语句就不返回值。现在的想只要x表或y表其中任何表存在记录时,就要显示字段出来,语句该怎么写?
select a,b from t
Union
select a,b from t2
select x.* .y.*
from (select a, b from t) x
left join (select a, b from t2) y on x.a = y.a
where (select count(*) from (select a, b from t)) >
(select count(*) from select a, b from t2
));select x.* .y.*
from (select a, b from t) x
right join (select a, b from t2) y on x.a = y.a
where (select count(*) from (select a, b from t)) <
(select count(*) from select a, b from t2
));
select x.*.y.* from (select a,b from t) x,(select a,b from t2)y
正常情况下得到 x.a,x.b,y.a,y.b如果用union,请问怎么写?
-------------------- --------------------
a bSQL> select * from t2;未选定行SQL> select x.*,y.* from
2 (select a,b from t) x full outer join
3 (select a,b from t2) y on 1=1;A B A
-------------------- -------------------- --------------------
B
--------------------
a b
from (select * from t1) x
full join (select * t2)y
on 1 = 1OK?
from (select * from t1) x
full join (select * t2)y
on 1 = 1