Heim > Fragen und Antworten > Hauptteil
A 表
user_id phone
1 1
2 2
B表
user_id mail
1 1
想连表得到C,没有找到相同user_id的默认为0
C表
user_id phone mail
1 1 1
2 2 0
mysql语句怎么写?
ringa_lee2017-04-17 13:56:19
select A.user_id as user_id,A.phone as phone,coalesce(B.mail,0) as mail
from A left join B on A.user_id=B.user_id