我有三个不同的查询。我可以混合它们并创建一个查询而不是这三个查询吗?
查询1:
UPDATE users SET reputation = reputation + 15,
money = money + (SELECT SUM(responder_amount)
FROM money WHERE post_id = :post_id AND paid IS NULL)
WHERE id = :Responder
QUERY2:
UPDATE users SET reputation = reputation + 2,
money = money + (SELECT SUM(op_amount)
FROM money WHERE post_id = :post_id AND paid IS NULL)
WHERE id = :OP
QUERY3:
UPDATE money SET paid = 1 WHERE post_id = :post_id
我可以用这三个查询组成一个查询吗?
答案 0 :(得分:-2)
如果您要更新同一列,您可以使用案例,但在您的示例中,
第一个和第二个可以写在1个更新语句中,但在第三个中你正在更新不同的列,在另一个表上,据我所知,我无法完成。