我有一个SQL查询,它按rand进行限制和顺序选择,因此我得到每个
status
然后混合整个结果,得到一个随机结果,而不是每个块
地位
,并按预期工作:
(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()
有什么建议吗?
谢谢