gpt4 book ai didi

mysql - Begin 语句的 SQL 错误 #1064

转载 作者:行者123 更新时间:2023-11-29 22:30:19 24 4
gpt4 key购买 nike

SQL

BEGIN
UPDATE gcm_users SET gcm_regid="fff" WHERE user_id=8;

IF sql%rowcount = 0 THEN
INSERT INTO gcm_users (gcm_regid, user_id) VALUES ("dsdtrytujytetgeryrtyh", "8");
END IF;
END;

Error : #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 'UPDATE gcm_users SET gcm_regid="dsdtrytujytetgeryrtyh" WHERE user_id=8' at line 2

编辑:

------------------------------------------------------------
| Id | user_id | gcm_regid | created_at | Status |
------------------------------------------------------------
| 1 | 22 | ********* | 2015-04-25 13:13:39 | 1 |
| 2 | 33 | ********* | 2015-04-25 13:13:39 | 1 |
| 3 | 13 | ********* | 2015-04-25 13:13:39 | 1 |
| 4 | 12 | ********* | 2015-04-25 13:13:39 | 1 |
| 5 | 67 | ********* | 2015-04-25 13:13:39 | 1 |
| 6 | 65 | ********* | 2015-04-25 13:13:39 | 1 |
------------------------------------------------------------

有人可以帮我解决这个错误吗?

最佳答案

SQL 中的字符串文字用单引号 (') 表示,而不是双引号 ("):

begin
UPDATE gcm_users SET gcm_regid='fff' WHERE user_id=8;

if sql%rowcount = 0 then
INSERT INTO gcm_users (gcm_users, user_id)
VALUES ('dsdtrytujytetgeryrtyh', 8);
end if;
end;

关于mysql - Begin 语句的 SQL 错误 #1064,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29865820/

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