A表
Card ManID
0001 0000000001
0002 0000000002
0003 0000000003
0004 0000000004
B表
Card Cent
0001 10
0003 5注意A表有的Card,B表不一定有,出来的结果是C表
Card ManID Cent
0001 0000000001 10
0002 0000000002 0
0003 0000000003 5
0004 0000000004 0我的数据库是mysql。在不建新表的情况下,这个语句怎么写才能实现C表的结果
Card ManID
0001 0000000001
0002 0000000002
0003 0000000003
0004 0000000004
B表
Card Cent
0001 10
0003 5注意A表有的Card,B表不一定有,出来的结果是C表
Card ManID Cent
0001 0000000001 10
0002 0000000002 0
0003 0000000003 5
0004 0000000004 0我的数据库是mysql。在不建新表的情况下,这个语句怎么写才能实现C表的结果
(Case when B.Cent is null then 0 else B.Cent end) as Cent from A left join B on A.Card=B.Card
select A.CardID,A.ManID,IsNull(B.Cent, 0) Cent
from A
left join B on A.CardID = B.CardID