各位高人前辈,帮忙看看这个句子update tc_customer
set cust_int029=case when
(tc_friend.friend_simple_code like'6688%' or tc_friend.friend_simple_code like'8866%'
or tc_friend.friend_simple_code like '6666%') and tc_friend.friend_id=tc_customer.friend_id and owner_id=1
then '1001' else '1002'end这个句子有问题,
两张表tc_customer,tc_friend,想看到的结果是当表tc_friend.friend_simple_code =6688或8866或6666是,把表tc_customer 的cust_int029 改成1001,其他情况改成1002
set cust_int029=case when
(tc_friend.friend_simple_code like'6688%' or tc_friend.friend_simple_code like'8866%'
or tc_friend.friend_simple_code like '6666%') and tc_friend.friend_id=tc_customer.friend_id and owner_id=1
then '1001' else '1002'end这个句子有问题,
两张表tc_customer,tc_friend,想看到的结果是当表tc_friend.friend_simple_code =6688或8866或6666是,把表tc_customer 的cust_int029 改成1001,其他情况改成1002
(b.friend_simple_code in('6688','8866','6666') then '1001' else '1002' end
from tc_customer a,tc_friend b
where b.friend_id=a.friend_id and a.owner_id=1
update tc_customer
set cust_int029=case when
(tc_friend.friend_simple_code like'6688%' or tc_friend.friend_simple_code like'8866%'
or tc_friend.friend_simple_code like '6666%') and then '1001' else '1002'end from tc_friend
where tc_friend.friend_id=tc_customer.friend_id and owner_id=1
update tc_customer
set cust_int029=case when tc_friend.friend_simple_code like'6688%' then '1001' else '1002'end ,
when tc_friend.friend_simple_code like'8866%' then '1001' else '1002'end ,
when tc_friend.friend_simple_code like '6666%' then '1001' else '1002'end
where tc_friend.friend_id=tc_customer.friend_id and owner_id=1
set a.cust_int029=case when b.friend_simple_code in('6688','8866','6666') then '1001' else '1002' end
from tc_customer a
join tc_friend b
on a.friend_id=b.friend_id
and a.owner_id=1
set a.cust_int029=case when b.friend_simple_code like'6688%' or b.friend_simple_code like'8866%' or b.friend_simple_code like '6666%' then '1001' else '1002' end
from tc_customer a
join tc_friend b
on a.friend_id=b.friend_id
and a.owner_id=1
这样再试试
set cust_int029=case when f.friend_simple_code like '6688%'
or f.friend_simple_code like '8866%'
or f.friend_simple_code like '6666%' then '1001'
else '1002'
end
from tc_customer c
inner join tc_friend f
on f.friend_id=c.friend_id
where c.owner_id=1
set cust_int029= (case when
(tc_friend.friend_simple_code like'6688%' or
tc_friend.friend_simple_code like'8866%' or
tc_friend.friend_simple_code like '6666%') and
tc_friend.friend_id=tc_customer.friend_id and owner_id=1
then '1001' else '1002'end)
FROM tc_customer
update tc_customer
set cust_int029=case when tc_friend.friend_simple_code like'6688%' then '1001' else '1002'end ,
when tc_friend.friend_simple_code like'8866%' then '1001' else '1002'end ,
when tc_friend.friend_simple_code like '6666%' then '1001' else '1002'end
where tc_friend.friend_id=tc_customer.friend_id and owner_id=1 应该是这样,在WHEN 里面条件不能那样连接