-1

MySQL said: Documentation

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INSERT INTO 'tblproduct' (id, name, code, image, price) VALUES(1, '3' at line 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);
Nigel Ren
  • 56,122
  • 11
  • 43
  • 55
Shubham Aher
  • 45
  • 1
  • 1
  • 11

1 Answers1

2

There are two problems in this a ; is missing after CREATE TABLE and also use backticks for 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);
moghya
  • 854
  • 9
  • 18