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

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

迷茫
迷茫

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

membalas semua(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

Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan