大家好我在将值插入表格时找不到错误。
它一直显示错误“#1064 - 您的SQL语法中有错误;请查看与您的MySQL服务器版本对应的手册,以便在''''1000000001','CASH','PAID附近使用正确的语法','2015-09-05 12:58:51','100000','10000005'), (第2行'10000' “
下面的编码是将值插入表调用order
:,
INSERT INTO `ORDER` VALUES
(`Order_ID`, `Pay_Method`, `Pay_status`, `Order_Time`, `Cus_ID`, `Emp_ID`)
('1000000001','CASH','PAID','2015-09-05 12:58:51','100000','10000005'),
('1000000002','CASH','PAID','2015-09-05 14:45:00','100001','10000008'),
('1000000003','CREDIT CARD','PAID','2015-09-05 16:34:21','100002','10000001'),
('1000000004','CASH','PAID','2015-09-05 17:10:10','100003','10000008'),
('1000000005','CREDIT CARD','PAID','2015-09-06 12:33:11','100004','10000006'),
('1000000006','CREDIT CARD','PAID','2015-09-06 15:51:15','100006','10000003'),
('1000000007','CASH','PAID','2015-09-06 16:20:05','100007','10000002'),
('1000000008','','UNPAID','2015-09-06 17:00:00','100005','10000005'),
('1000000009','','UNPAID','2015-09-06 17:23:15','100008','10000001'),
('1000000010','','UNPAID','2015-09-06 17:30:34','100009','10000006')
这是表创建的编码:(创建成功)
CREATE TABLE `ORDER` (
Order_ID CHAR(10) PRIMARY KEY,
Pay_Method ENUM ('CASH','CREDIT CARD') NOT NULL,
Pay_status ENUM ('PAID','UNPAID') NOT NULL,
Order_Time DATETIME NOT NULL,
Total_Price DECIMAL(6,2) NOT NULL,
Cus_ID CHAR(6) NOT NULL,
FOREIGN KEY (Cus_ID) REFERENCES CUSTOMER(Cus_ID) ON DELETE CASCADE ON UPDATE CASCADE,
Emp_ID CHAR(8) NOT NULL,
FOREIGN KEY (Emp_ID) REFERENCES EMPLOYEE(Emp_ID) ON DELETE CASCADE ON UPDATE CASCADE
)
我没有插入Total Price
的值,因为我稍后会插入它。
提前谢谢你。
答案 0 :(得分:2)
字段位于表名后面:
INSERT INTO _table_ (field1, field2, ...) VALUES (...)
答案 1 :(得分:2)
INSERT INTO `ORDER`
(`Order_ID`, `Pay_Method`, `Pay_status`, `Order_Time`, `Cus_ID`, `Emp_ID`)
VALUES
('1000000001','CASH','PAID','2015-09-05 12:58:51','100000','10000005'),
...