gpt4 book ai didi

php - Insert Join with limit - Mysql

转载 作者:行者123 更新时间:2023-11-29 05:08:23 25 4
gpt4 key购买 nike

如何在使用限制的同时通过连接进行更新

错误 - 限制运算符的非法使用

UPDATE  
table1
INNER JOIN table2 ON table1.id = table2.id
SET
table1.field = 'your_value'
WHERE
table1.id = table2.id
LIMIT 1500

最佳答案

可能的解决方案,有点hack

SET @tmp_c = 0;
UPDATE
table1
INNER JOIN table2 ON table1.id = table2.id
INNER JOIN table3 ON table2.id = table3.id
SET
table1.remove_date = NOW() - INTERVAL 5 MONTH
WHERE
table1.active = 1
AND
(IF (table1.active = 1, @tmp_c := @tmp_c + 1 , 0 )) //This is to only increment the counter if the whole where matches
AND
@tmp_c <= 15 //Start ignoring row items as soon as it exceeds the limit amount

;

关于php - Insert Join with limit - Mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44050624/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com