看板 Database 關於我們 聯絡資訊
update t1 set A1 = case when t1.A2 = t2.B2 then t2.B1 else t3.B1 end from A t1 left join B t2 on t1.A2 = t2.B2 left join B t3 on t3.B2 = 'ALL' where t1.A2 = t2.B2 or t3.B2 = 'ALL' ※ 引述《redskyism (dreamer)》之銘言: : 資料庫名稱:MSQL : 資料庫版本: : 內容/問題描述: : 請教SQL : update A set A.A1 = B.B1 from A inner join B on A.A2 = B.B2 : 想在B2 中增加"All"的資料,若資料有A2對應不到B2時則找 B2='All' : 的資料,請問該怎麼寫比較好呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.168.31.46 ※ 文章網址: https://www.ptt.cc/bbs/Database/M.1511886443.A.50D.html ※ 編輯: cutekid (1.168.31.46), 11/29/2017 00:41:15
redskyism: 感謝~~ 11/29 00:47