gpt4 book ai didi

mysql - SQL 代码中的语法错误

转载 作者:行者123 更新时间:2023-11-29 05:08:46 25 4
gpt4 key购买 nike

我有用于将测试值插入数据库的 sql 代码:

INSERT INTO log (from, value) VALUES ('ABC', 'DEF')

我有表log:

from | value

fromvaluevarchar(255)

当我运行我的代码时出现错误:

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, value) VALUES ('ABC', 'DEF')' at line 1

我不知道为什么,你能给我建议吗?我的代码有语法错误?或者什么?

最佳答案

from 是一个 MySQL 关键字。如果可以,重命名该列。

ALTER TABLE `log`
CHANGE COLUMN `from` `something_else` VARCHAR(255)

如果不能,请在列名周围使用反引号。

INSERT INTO `log` (`from`, `value`) VALUES ('ABC', 'DEF')

关于mysql - SQL 代码中的语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43156378/

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