作者chunhsiang (= =)
看板Database
标题Re: [SQL ] 请问要如何搜寻两张资料表
时间Wed Aug 31 18:38:49 2011
※ 引述《phreat (雷)》之铭言:
: 请问一下
: 以下为两张表
: table a
: id enable
: 1
: 2 1
: 3 1
: 4 1
: table b
: id enable
: 4 1
: 5 1
: 6 1
: 请问有办法印出
: id enable
: 2 1
: 3 1
: 4 1
: 4 1
: 5 1
: 6 1
: 测试过FULL JOIN , UNION 等都无法达成如果使用
: select * from a as a ,b as b
: 会变成
: id enable id enable
: ....
: ....
: ....
: ....
select a.id as id, a.enable as enable
from a
where a.enable is not null
union all
select b.id, b.enable
from b
where b.enable is not null
;
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.37.103.210
1F:→ chunhsiang:union all 是重点吧 他可以将重复的视为不一样的 08/31 18:40