gpt4 book ai didi

mysql - SQL联盟更新

转载 作者:行者123 更新时间:2023-11-29 06:53:05 26 4
gpt4 key购买 nike

我有这个 SQL 查询,它通过限制进行选择并按 rand 排序,因此我得到每个 status 的设定编号,然后混合整个结果以获得随机结果,而不是每个 的 block 状态,并且按预期工作:

(SELECT * FROM `vicidial_list` WHERE phone_number LIKE "7%" AND list_id NOT IN (500,1000) AND status = "AR" LIMIT 1038)
UNION
(SELECT * FROM `vicidial_list` WHERE phone_number LIKE "7%" AND list_id NOT IN (500,1000) AND status = "CBHOLD" LIMIT 372)
UNION
(SELECT * FROM `vicidial_list` WHERE phone_number LIKE "7%" AND list_id NOT IN (500,1000) AND status = "NEW" LIMIT 3824)
UNION
(SELECT * FROM `vicidial_list` WHERE phone_number LIKE "7%" AND list_id NOT IN (500,1000) AND status = "PI" LIMIT 1405)
UNION
(SELECT * FROM `vicidial_list` WHERE phone_number LIKE "7%" AND list_id NOT IN (500,1000) AND status = "NRP" LIMIT 500)
UNION
(SELECT * FROM `vicidial_list` WHERE phone_number LIKE "7%" AND list_id NOT IN (500,1000) AND status = "RCAT" LIMIT 500)
ORDER BY RAND()

现在我希望将 list_id 更新为 200,但这不起作用:

(UPDATE `vicidial_list` SET list_id = 200 WHERE phone_number LIKE "7%" AND list_id NOT IN (500,1000) AND status = "AR" LIMIT 1038)
UNION
(UPDATE `vicidial_list` SET list_id = 200 WHERE phone_number LIKE "7%" AND list_id NOT IN (500,1000) AND status = "CBHOLD" LIMIT 372)
UNION
(UPDATE `vicidial_list` SET list_id = 200 WHERE phone_number LIKE "7%" AND list_id NOT IN (500,1000) AND status = "NEW" LIMIT 3824)
UNION
(UPDATE `vicidial_list` SET list_id = 200 WHERE phone_number LIKE "7%" AND list_id NOT IN (500,1000) AND status = "PI" LIMIT 1405)
UNION
(UPDATE `vicidial_list` SET list_id = 200 WHERE phone_number LIKE "7%" AND list_id NOT IN (500,1000) AND status = "NRP" LIMIT 500)
UNION
(UPDATE `vicidial_list` SET list_id = 200 WHERE phone_number LIKE "7%" AND list_id NOT IN (500,1000) AND status = "RCAT" LIMIT 500)
ORDER BY RAND()

有什么建议吗?

谢谢。

最佳答案

只需将每个 UPDATE 作为单独的语句运行即可:

UPDATE `vicidial_list` SET list_id = 200 WHERE phone_number LIKE "7%" AND list_id NOT IN (500,1000) AND status = "AR" ORDER BY RAND() LIMIT 1038;
UPDATE `vicidial_list` SET list_id = 200 WHERE phone_number LIKE "7%" AND list_id NOT IN (500,1000) AND status = "CBHOLD" ORDER BY RAND() LIMIT 372;
UPDATE `vicidial_list` SET list_id = 200 WHERE phone_number LIKE "7%" AND list_id NOT IN (500,1000) AND status = "NEW" ORDER BY RAND() LIMIT 3824;
UPDATE `vicidial_list` SET list_id = 200 WHERE phone_number LIKE "7%" AND list_id NOT IN (500,1000) AND status = "PI" ORDER BY RAND() LIMIT 1405;
UPDATE `vicidial_list` SET list_id = 200 WHERE phone_number LIKE "7%" AND list_id NOT IN (500,1000) AND status = "NRP" ORDER BY RAND() LIMIT 500;
UPDATE `vicidial_list` SET list_id = 200 WHERE phone_number LIKE "7%" AND list_id NOT IN (500,1000) AND status = "RCAT" ORDER BY RAND() LIMIT 500;

关于mysql - SQL联盟更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46735072/

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