0

我不断收到此错误

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM `rate` R, `temp` T WHERE R.`rate` > T.`rate` AND `rate`.`prefix` LIKE C'

这是我的查询

UPDATE  R
SET  R.rate =  T.rate,
R.vendor = T.provider,
FROM rate R, temp T
WHERE R.rate > T.rate 
AND  R.prefix LIKE CONCAT(T.prefix,  '%' ) 
ORDER BY LENGTH( T.prefix ) DESC LIMIT 1;
4

2 回答 2

1

您使用了不正确的 MySQL 语法。

UPDATE  rate R join
        `temp` T
        on R.`rate` > T.`rate` AND R.`prefix` LIKE CONCAT(T.`prefix`,  '%' )
    SET  R.`rate` =  T.`rate`,
         R.`vendor` = T.`provider`
    ORDER BY LENGTH( T.`prefix` ) DESC
    LIMIT 1;

set但是,您的直接问题是第二个语句末尾的额外逗号。

于 2013-09-09T20:08:37.023 回答
0

尝试:

UPDATE rate r, temp t
    SET r.rate = t.rate, r.vendor = t.provider
    WHERE r.rate > t.rate 
        AND r.prefix LIKE CONCAT(t.prefix,  '%')
于 2013-09-09T20:09:01.503 回答