php - mysql_query和php语法错误问题

标签 php mysql database syntax

我在 php 中执行 mysql 查询时遇到问题 查询是

INSERT INTO rfqtable (rfqnumber, prnumber, linenumber, shipmentnumber, item, desc, needbydate, uom, rfqqty, quotedqty, unitprice, amountprice, lt, substitute, remark, coc, tds, exportlicense, maker, quotedmaker, substituteinfo, validuntil, warranty, program, packingtype, attachment)VALUES('63915', '86298', '1', '1', '229-027477', 'WASHER, SEALING', 'AUG-26-2011', 'Each', '50', '0', '0', '0', '0', '', '', 'N', 'N', '', '', '', '', '0', '0', 'KFP', '', '')

mysql错误是:

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, needbydate, uom, rfqqty, quotedqty, unitprice, amountprice, lt, substitute' at line 1

都是varchar 255字段,utf-8通用

任何帮助将不胜感激

最佳答案

DESCMySQL's reserved word 。如果你想用它作为列名,你需要把它放在反引号(``)

INSERT INTO rfqtable (
  rfqnumber, prnumber, linenumber, shipmentnumber, item, `desc`,
  needbydate, uom, rfqqty, quotedqty, unitprice, amountprice, lt,
  substitute, remark, coc, tds, exportlicense, maker, quotedmaker, 
  substituteinfo, validuntil, warranty, program, packingtype, attachment
) VALUES (
  '63915', '86298', '1', '1', '229-027477', 'WASHER, SEALING',
  'AUG-26-2011', 'Each', '50', '0', '0', '0', '0', '', '', 'N',
  'N', '', '', '', '', '0', '0', 'KFP', '', '')

另外:为了您自己的利益,请使用正确的数据类型。将日期和数字存储为 VARCHAR 可能是最糟糕的事情。 http://dev.mysql.com/doc/refman/5.5/en/data-types.html

关于php - mysql_query和php语法错误问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6933266/

相关文章:

php - 如何从我的查询中只访问一条记录

mysql - 获取列名称以及第一行值?

java - 从 XML 记录到关系的无损模式映射

java - 这个 Java JDBC 程序有什么问题?

php - mysql 使用用户名计算用户推荐 |出现错误

PHP网站优化

php - 数据库未正确存储希腊字符

php - 防止在 laravel 中重新提交后路由

php - Android 到 PHP API 安全

php - 通知用户数据库更改