我遇到此错误并被卡在上面,我只是找不到sql错误! 我收到此错误
错误:ER_PARSE_ERROR:您的SQL语法有错误;在第1行上,检查与您的MySQL服务器版本相对应的手册,以在“ x迪士尼– Lautsprecherfürdie Dusche mit Micky Maus-Design,asos,Typo,nul”附近使用正确的语法
对应于main.json.result [1] +“,” +
module.exports = { products_into_db:函数(){
const insert_products = db_config.fetch("INSERT INTO asos_products " +
"(handle, title,vendor,category,type,gender,color,brand,price,beforeSalePrice,currency,product_code) " +
"VALUES (" +
main.json.result[0] + ", "+
main.json.result[1] + ", " +
main.json.result[2] + ", " +
main.json.result[3] + ", " +
main.json.result[4] + ", " +
main.json.result[5] + ", "+
main.json.result[6] + ", " +
main.json.result[7] + ", " +
main.json.result[8] + ", " +
main.json.result[9] + ", " +
main.json.result[11] + ", " +
main.json.result[12] + ") "
)
return insert_products
这是我的sql表:
CREATE TABLE `asos_products` (
`internal_id` bigint(20) NOT NULL AUTO_INCREMENT,
`handle` varchar(70) NOT NULL,
`title` varchar(70) NOT NULL,
`vendor` varchar(30) NOT NULL,
`category` varchar(30) DEFAULT NULL,
`type` varchar(30) DEFAULT NULL,
`gender` varchar(10) DEFAULT NULL,
`color` varchar(30) DEFAULT NULL,
`brand` varchar(40) DEFAULT NULL,
`price` float NOT NULL,
`beforeSalePrice` float DEFAULT NULL,
`currency` varchar(3) NOT NULL,
`product_code` int(30) DEFAULT NULL,
PRIMARY KEY (`internal_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
SELECT * FROM enroute.asos_products;
答案 0 :(得分:0)
将main.json.result [i]包围在具有varchar类型的列的逗号中间。示例-
", '" +
main.json.result[5] + "', "+
那应该可以工作