-2
UPDATE devicenumplanmap 
SET devicenumplanmap.e164mask = '+1' 
FROM devicenumplanmap 
WHERE (select devicenumplanmap.pkid, devicenumplanmap.e164mask 
       from devicenumplanmap, device 
       where devicenumplanmap.fkdevice = device.pkid 
         and device.name like '%RDP' 
         and devicenumplanmap.e164mask like '819%')

出现语法错误。

我们想通过在另一个表中的搜索来更新表 devicenumplanmap。

4

3 回答 3

1

看起来您正在尝试UPDATE使用JOIN. 根据您的 RDBMS,语法略有不同。

MySQL:

UPDATE devicenumplanmap d
    JOIN device de ON d.fkdevice = de.pkid
SET d.e164mask = '+1' 
WHERE de.name like '%RDP' 
       AND d.e164mask like '819%'

SQL 服务器:

UPDATE  d
SET d.e164mask = '+1' 
FROM devicenumplanmap d 
    JOIN device de ON d.fkdevice = de.pkid
WHERE de.name like '%RDP' 
       AND d.e164mask like '819%'

更通用的方法:

UPDATE devicenumplanmap 
SET e164mask = '+1' 
WHERE e164mask like '819%' AND
    fkdevice IN (
        SELECT pkid
        FROM Device 
        WHERE name like '%RDP' 
)
于 2013-05-30T20:45:24.743 回答
0

尝试这样的事情:

UPDATE devicenumplanmap 
SET devicenumplanmap.e164mask = '+1' 
FROM devicenumplanmap 
WHERE **exists(select ***
       from devicenumplanmap, device 
       where devicenumplanmap.fkdevice = device.pkid 
         and device.name like '%RDP' 
         and devicenumplanmap.e164mask like '819%')
于 2013-05-30T20:44:42.140 回答
0

这应该适用,简单易行

UPDATE devicenumplanmap
SET devicenumplanmap.e164mask = '+1' 
FROM devicenumplanmap dp 
INNER JOIN device d
ON dp.fkdevice = d.pkid
WHERE d.name like '%RDP' 
and dp.e164mask like '819%'
于 2013-05-30T20:50:54.787 回答