mysql连表
迷茫
迷茫 2017-04-17 13:54:19
0
1
583

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语句怎么写?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all (1)
左手右手慢动作

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

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!