【发布时间】:2011-10-30 04:38:30
【问题描述】:
我有一个关于复杂选择的问题 (link), 我的问题是,如何为这个查询的结果编写一个更新查询,将 fet_id 更改为某个新值。
请注意,此查询将从队列中选择行,直到 rcpts_count 达到 1000,(用于流量控制)。有关此查询的更多信息是,in this question
SELECT NULL AS msg_id, NULL AS total, NULL AS found
FROM dual
WHERE (
@total :=0
OR
@found :=0
)
UNION
SELECT msg_id, @total AS total, @found :=1 AS found
FROM messages_queue
WHERE (
@total := @total + rcpts_count
)
AND @total <1000
UNION
SELECT msg_id, rcpts_count AS total, 0 AS found
FROM messages_queue
WHERE IF( @found =0, @found :=1, 0 )
【问题讨论】:
-
是否要更新上表返回的集合中的所有记录,将字段“fet_id”设置为整个集合的单个值?
标签: mysql sql sql-update