php - 无法在 mysql 中使用列名 "desc"

标签 php mysql web

INSERT INTO movie (id, title, desc, released, views, featured) VALUES ('', 'title', '
\r\n    description
\r\n', '2006-12-12', '0', '0')

错误是

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 'desc, released, views, featured) VALUES ('', 'title', ' \r\n description \r\n', ' at line 1

表结构为

id [ (pk, auto_inc) int(11) ]
title [ varchar(256) ]
desc [ text ]
released [ date ]
views [ int(11) ]
featured [ int(11) ]

在 phpmyadmin sql 编辑器中运行

最佳答案

desc 是一个 mysql reserved word .您必须对保留字列使用反引号 ``。

INSERT INTO movie (id, title, `desc`, released, views, featured)...

你应该避免使用保留字作为列名或者必须使用反引号(``)

关于php - 无法在 mysql 中使用列名 "desc",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8200174/

相关文章:

php - 选择多个id的php/mysql

javascript - 如何访问从 PHP 收到的 ajax 响应中的数组元素?

php - 无法在 Eloquent/Query Builder 中使用多个占位符

php - 请为初学者解释这个 .htaccess 文件

php - 如何在 MYSQL 中存储 PDF 文件的文件引用以在 php 中检索

mysql - SQL 左连接插入不起作用

java - c3p0 maxIdleTime 和 mysql 的 wait_timeout 一样吗?

node.js - Web 服务器(tomcat、jboss..etc)可以与 nodejs 通信吗?

tcp - DNS二级域名查询

web - 如何在 Fiddler 中显示请求发送时间和响应接收时间?