2017-10-07 69 views
-2

我有两个表A和BI正在使用左连接和查询将返回两列电话,CID像这样如何将值从一列分配给mysql中的另一列?

select B.phone 
    , A.cid 
    from B 
    left 
    join A 
    on A.id_cc_card = cc_card.id 
where A.cid is null 


phone  cid 
5656565 null 
4546565 null 

现在我的问题是我要指派手机的价值用mysql这样

到CID
phone cid 
    5656565 5656565 
    4546565 4546565 

任何帮助,将不胜感激。

+0

参见COALESCE()。 – Strawberry

+1

为什么问两次相同的问题https://stackoverflow.com/questions/46629692/how-to-update-value-from-one-column-to-another-in-left-join-query-result/46629811#46629811 –

回答

0

试试这个。你会得到你想要的结果,在你提到的问题。

select B.phone,B.phone as cid from B left join A on 
A.id_cc_card=cc_card.id where A.cid is null 
+0

我想从phone列中将值分配给cid列。 –

相关问题