我在 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通用
任何帮助将不胜感激
最佳答案
DESC
是 MySQL'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/