用户定义的变量在WHERE语句中不起作用(在UPDATE中)

时间:2015-04-23 10:43:48

标签: mysql sql triggers

new_val=$(echo $i | cut -d '.' -f 1)
grep $new_val "/nav/lab/xyz.lst"

begin DECLARE t_order_id INT; DECLARE t_not_send INT; SELECT o.id, IF(SUM(IFNULL(rr.return, 0)) != SUM(IFNULL(rr.storage, 0)), 1, 0) INTO @t_order_id, @t_not_send FROM orders o LEFT JOIN sample_return_product srp ON o.id = srp.order_id LEFT JOIN return_registry rr ON srp.fin_in_id = rr.fin_in_id WHERE id = 10 GROUP BY o.id; INSERT INTO `DUAL` (id,flag) VALUES (@t_order_id, @t_not_send); UPDATE `orders` SET not_send = @t_not_send WHERE **id = @t_order_id;** end 工作正常,但INSERT无效,我不明白为什么。如果UPDATE中没有WHERE,则更新查询正常。你能救我吗?

0 个答案:

没有答案