求一句SQL语句
select
a.d1,
a.d2,
a.d3,
a.d4,
b.d2, ---
c.d1, ---
a.d5
from
t1 a,
t2 b,
t3 c
where
a.d0 = b.d0 and
a.d6 = c.d6 and
a.d7 = 'XXXXX'
类似一个这样的语句,如果B、C表里没有记录,就查不到数据。但我希望,如果B、C没有记录时,A表的记录仍然显示,B.d2、C.d1用0代替。
(分不够,不好意思)
[解决办法]
select a.d1,a.d2,a.d3,a.d4,isnull(b.d2, 0) as d2, ---isnull(c.d1, 0) as d1, ---a.d5 from t1 aleft joint2 bon a.d0 = b.d0left joint3 c on a.d6 = c.d6 where a.d7 = 'XXXXX'