UPDATE tbl_bonuses AS B
INNER JOIN tbl_member AS V
ON B.recepient_code = V.user_id
SET B.points = B.points + 15, B.ctr = B.ctr + 15
WHERE user_id IN (SELECT user_id from tbl_member LIMIT 10);
ERROR:
#1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
使用多个参数进行多次更新的任何其他方式而不使用(in)?
答案 0 :(得分:1)
将子查询包装在派生表中
UPDATE tbl_bonuses AS B
INNER JOIN tbl_member AS V
ON B.recepient_code = V.user_id
SET B.points = B.points + 15, B.ctr = B.ctr + 15
WHERE user_id IN (SELECT user_id FROM (
SELECT user_id from tbl_member LIMIT 10
) t
);
答案 1 :(得分:1)
MySQL在某些子查询运算符的子查询中不支持LIMIT:
的MySQL> SELECT * FROM t1 - >在哪里s1 IN(选择s2从t2 ORDER by s1 LIMIT 1); ERROR 1235(42000):此版本的MySQL尚不支持 '限制& IN / ALL / ANY / SOME子查询' 优化器对于连接比对子查询更成熟,因此在许多情况下,如果将其重写为连接,则可以更有效地执行使用子查询的语句。
可以将IN子查询重写为SELECT DISTINCT连接的情况发生异常。例如:
SELECT col FROM t1 WHERE id_col IN(SELECT id_col2 FROM t2 WHERE condition); 该声明可以改写如下:
SELECT DISTINCT col FROM t1,t2 WHERE t1.id_col = t2.id_col AND condition; 但在这种情况下,连接需要额外的DISTINCT操作,并且不比子查询更有效。
请参阅此link