MySQL语法错误#1064 INSERT INTO

时间:2018-04-01 06:43:00

标签: php mysql phpmyadmin

MySQL说:文档

  

#1064 - 您的SQL语法出错;查看与MariaDB服务器版本对应的手册,以获取正确的语法   靠近' INSERT INTO&#t; tblproduct' (idnamecodeimage,   price)价值观(1,' 3'第11行

CREATE TABLE IF NOT EXISTS `tblproduct` (
`id` int(8) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`code` varchar(255) NOT NULL,
`image` text NOT NULL,
`price` double(10,2) NOT NULL,
 PRIMARY KEY (`id`),
 UNIQUE KEY `product_code` (`code`)
 )

 INSERT INTO 'tblproduct' (`id`, `name`, `code`, `image`, `price`) VALUES
 (1, '3D Camera', '3DcAM01', 'product-images/camera.jpg', 1500.00),
 (2, 'External Hard Drive', 'USB02', 'product-images/external-hard-drive.jpg', 800.00),
 (3, 'Wrist Watch', 'wristWear03', 'product-images/watch.jpg', 300.00);

1 个答案:

答案 0 :(得分:2)

此问题有两个问题; CREATE TABLE后遗失tblproduct并且CREATE TABLE IF NOT EXISTS `tblproduct` ( `id` int(8) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `code` varchar(255) NOT NULL, `image` text NOT NULL, `price` double(10,2) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `product_code` (`code`) ); INSERT INTO `tblproduct` (`id`, `name`, `code`, `image`, `price`) VALUES (1, '3D Camera', '3DcAM01', 'product-images/camera.jpg', 1500.00), (2, 'External Hard Drive', 'USB02', 'product-images/external-hard-drive.jpg', 800.00), (3, 'Wrist Watch', 'wristWear03', 'product-images/watch.jpg', 300.00); 使用反引号

{
  "name": "vue-mini-social-network",
  "version": "1.0.0",
  "description": "A mini-social-network created with VueJS!!",
  "main": "app.js",
  "scripts": {
    "start": "nodemon app.js",
    "dev": "webpack -d --watch",
    "build": "webpack -p --watch"
  }
}