MySql过程正在更新错误的条件

时间:2015-10-15 19:08:50

标签: mysql

MySQL Procedure正在更新所有3条记录并且无法执行条件。

我有三条记录的表,其中三条记录的分支ID = 1,2,3和UID相同。我正在根据分支ID更新,但我的查询正在更新所有3条记录。???? 任何帮助plzzz。

CREATE DEFINER=`root`@`localhost` PROCEDURE `update_scheduler_minmax`(
    IN minVolt DOUBLE,
    IN min_volt_time timestamp,
    IN branch int)
BEGIN
    UPDATE min_max SET 
        MIN_VOLT = minVolt,
        MIN_VOLT_TIME = min_volt_time        
        WHERE BRANCH = branch AND DEVICE_ID = 'XXXXXXXXXXXXXUID';
END

1 个答案:

答案 0 :(得分:1)

尝试:

DELIMITER $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `update_scheduler_minmax`(
    IN `_minVolt` DOUBLE,
    IN `_min_volt_time` timestamp,
    IN `_branch` int)
BEGIN
    UPDATE `min_max`
    SET `MIN_VOLT` = `_minVolt`, `MIN_VOLT_TIME` = `_min_volt_time`       
    WHERE `BRANCH` = `_branch` AND `DEVICE_ID` = 'XXXXXXXXXXXXXUID';
END$$

DELIMITER ;