我有以下问题:
Select PERSON_NAME, Mobile_Nr, replace(Message, 'text 8' ,'yes') as SMSs from PERSON a
inner join USER_MOBILE b on a.ID_PERSON=b.ID_USER
inner join MOBILE_NUMBER c on b.ID_MOBILE=C.ID
inner join MESSAGE_ID d on c.ID=d.ID_Mobile
where a.Person_Name not in
(Select PERSON_NAME from PERSON a
inner join USER_MOBILE b on a.ID_PERSON=b.ID_USER
inner join MOBILE_NUMBER c on b.ID_MOBILE=C.ID
inner join CALL_ID d on c.ID=d.ID_Mobile)
返回:
PERSON_NAME Mobile_Nr SMSs
First name 5 Last name 5 797900012 yes
First name 5 Last name 5 797900012 text 9
First name 5 Last name 5 797900016 text 13
如何在查询中将短信中的所有值更改为是?
答案 0 :(得分:2)
不确定我是否理解正确。这就是你想要的吗?
Select PERSON_NAME, Mobile_Nr, SMSs = 'Yes' from PERSON a
inner join USER_MOBILE b on a.ID_PERSON=b.ID_USER
inner join MOBILE_NUMBER c on b.ID_MOBILE=C.ID
inner join MESSAGE_ID d on c.ID=d.ID_Mobile
where a.Person_Name not in
(Select PERSON_NAME from PERSON a
inner join USER_MOBILE b on a.ID_PERSON=b.ID_USER
inner join MOBILE_NUMBER c on b.ID_MOBILE=C.ID
inner join CALL_ID d on c.ID=d.ID_Mobile)
答案 1 :(得分:0)
这是你想要做的(假设'消息'列在'MESSAGE_ID'表中)?
UPDATE MESSAGE_ID SET Message='Yes'
FROM PERSON a
inner join USER_MOBILE b on a.ID_PERSON=b.ID_USER
inner join MOBILE_NUMBER c on b.ID_MOBILE=C.ID
inner join MESSAGE_ID d on c.ID=d.ID_Mobile
where a.Person_Name not in
(Select PERSON_NAME from PERSON a
inner join USER_MOBILE b on a.ID_PERSON=b.ID_USER
inner join MOBILE_NUMBER c on b.ID_MOBILE=C.ID
inner join CALL_ID d on c.ID=d.ID_Mobile)