php - mysql基本插入语句错误1064

标签 php mysql

我有以下查询:

INSERT INTO user ('username', 'password', 'email', number) 
VALUES ('user123', '123', 'email123@hotmail.com', 2)

我得到了错误:

#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 ''username', 'password', 'email', space) VALUES('user123', '123', 'email123@hotmail.com', 2)

还有一个自增字段(mediumint),显然在sql语句中没有提到。可以吗?

请帮我解决这个问题。

最佳答案

使用反引号(在“1”键的左侧)而不是那里的引号:

INSERT INTO user (`username`, `password`, `email`, `number`) 
VALUES ('user123', '123', 'email123@hotmail.com', 2)

关于php - mysql基本插入语句错误1064,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27846635/

相关文章:

php - 在没有数据库的情况下管理动态内容的最佳方式

php - 具有许多属性的不可变对象(immutable对象)

mysql - slick 中存在查询

mysql - 在两个表上使用 where 子句使用 mysql left join 获取数据

mysql - 如何在此查询中获得 DISTINCT

php - 从时间戳中选择日期 php mysql

php - Symfony 2.1 - 未捕获的 PHP 异常 Twig_Error_Runtime

php - Wordpress 作为每个国家/地区不同页面内容的 cms

mysql - 在没有 Intersect 的 MariaDB 中进行 Intersect 查询时出错

mysql - 在 docker swarm 中将 mysql 容器扩展到 1 个以上时出现 mysql 连接问题