gpt4 book ai didi

MySql更新过程错误

转载 作者:行者123 更新时间:2023-11-29 22:39:48 26 4
gpt4 key购买 nike

我的更新查询有问题。我需要让它发挥作用:P

该过程选择所有重复的记录(需要重新创建以选择和更新值)

DELIMITER $$
USE `bgw_r`$$
DROP PROCEDURE IF EXISTS `tpl_pobierz_dodane`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `tpl_pobierz_dodane`(puzytkownik VARCHAR(50), psesja VARCHAR(50))
BEGIN
SELECT a.`id` AS idd FROM `paliwa_temp` AS a INNER JOIN `paliwo_fv` AS b
ON (a.`numerRejestracyjny` = b.`numer_rejestracyjny`)
WHERE a.`sesja` = psesja AND b.`data_tankowania` = a.`dataTankowania` AND a.`iloscPaliwa` = b.`wydano_litry`; # GROUP BY id
END$$
DELIMITER ;

或创建其他更新该值的过程:

DELIMITER $$
USE `bgw_r`$$
DROP PROCEDURE IF EXISTS `tpl_ustaw_jako_duplikaty`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `tpl_ustaw_jako_duplikaty`(puzytkownik VARCHAR(50), psesja VARCHAR(50))
BEGIN
UPDATE a
SET a.`duplikat` = "true"
FROM `paliwa_temp` AS a
INNER JOIN `paliwo_fv` AS b
ON( b.`numer_rejestracyjny` = a.`numerRejestracyjny`)
WHERE a.`sesja` = psesja AND b.`data_tankowania` = a.`dataTankowania` AND a.`iloscPaliwa` = b.`wydano_litry`;
END$$
DELIMITER ;

更新查询时出错:错误代码:1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM `paliwa_temp` as a
INNER JOIN `paliwo_fv` as b
on( b.`numer_rejestracyjny' at line 5

不知道为什么:/

最佳答案

正确的连接更新语句应该是

update paliwa_temp a
INNER JOIN `paliwo_fv` AS b
ON( b.`numer_rejestracyjny` = a.`numerRejestracyjny`)
SET a.`duplikat` = "true"
WHERE a.`sesja` = psesja
AND b.`data_tankowania` = a.`dataTankowania`
AND a.`iloscPaliwa` = b.`wydano_lit

关于MySql更新过程错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29407581/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com