Re: [SQL ]update A from B 多重条件

楼主: cutekid (可爱小孩子)   2017-11-29 00:27:20
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'
: 的资料,请问该怎么写比较好呢?
作者: redskyism (dreamer)   2017-11-29 00:47:00
感谢~~

Links booklink

Contact Us: admin [ a t ] ucptt.com