sql 遇到多个重复列名报错:Ambiguous column reference ***
生活随笔
收集整理的這篇文章主要介紹了
sql 遇到多个重复列名报错:Ambiguous column reference ***
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.執行下段sql報錯,原因是a表和b表都有user_log_acct,item_third_cate_cd,它不會自動合并一列的!!只會有兩列都叫這個,故c表里有兩列user_log_acct,沒辦法和d表匹配上!
SELECT* FROM(SELECT*from(select*from表1wheredt = '2018-05-30'and tp = '13252'and pv_15 > 1)aLEFT JOIN(select*from表2wheredt = '2018-05-30'and item_third_cate_cd = '13252'and order_7 > 0)bON(a.user_log_acct = b.user_log_acctand a.item_third_cate_cd = b.item_third_cate_cd)WHEREb.user_log_acct is NULL)c LEFT JOIN(selectuser_log_acct,item_third_cate_cd,1 as labelfrom表3wheredt = '2018-06-04'and item_third_cate_cd = '13252'and order_5 > 0)d ON(c.user_log_acct = d.user_log_acctand c.cateId = d.item_third_cate_cd) whered.user_log_acct is not NULL and d.item_third_cate_cd is not null2.后來嘗試在a表取別名,發現也不行,因為這意味有三列user_log_acct,只不過有一列叫pin,其他兩列還是重名的!這個問題就不太好解決,除非你把2000多個特征(除了user_log_acct)都列出來
(selecta.user_log_acct as pin,a.*,b.*from表1wheredt = '2018-05-30'and tp = '13252'and pv_15 > 1)a3.最后解決:在python中寫spark sql,在a和b關聯后,用drop函數去除b表中重復列總結
以上是生活随笔為你收集整理的sql 遇到多个重复列名报错:Ambiguous column reference ***的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PSTN与VoIP
- 下一篇: hdu 3966 (树链剖分,树状数组/