日期:2014-05-19  浏览次数:20746 次

这样的SQL语句应该怎样写??
表A中有字段fdA

当A.fdA= 'A '
取表B中所有字段
否则
取表C中所有字段



------解决方案--------------------
select f1,f2,f3,....
from (
select b.f1,b.f2,b.f3...., 'a ' as b.fa
from b
union all
select c.f1,c.f2,c.f3...., 'b ' as c.fa
from c) as t
where t.fa in (select fda from a)