一、表结构分析
1.订单表:orders
1.1建表语句
CREATE TABLE orders(
id INT AUTO_INCREMENT PRIMARY KEY,
orderNum VARCHAR(20) NOT NULL UNIQUE,
orderTime TIMESTAMP,
peopleCount INT,
orderDesc VARCHAR(500),
payType INT,
orderStatus INT,
productId INT,
memberId INT,
FOREIGN KEY (productId) REFERENCES product(id),
FOREIGN KEY (memberId) REFERENCES member(id)
)ENGINE=INNODB DEFAULT CHARSET=utf8mb4
1.2测试数据
INSERT INTO ORDERS (ordernum, ordertime, peoplecount, orderdesc, paytype, orderstatus,
productid, memberid) VALUES ('54311', 20180302120000, 2, '没什么', 0, 1, 2,1);
INSERT INTO ORDERS (ordernum, ordertime, peoplecount, orderdesc, paytype, orderstatus,
productid, memberid) VALUES ('54331', 20180302120000, 2, '没什么', 0, 1, 2,2);
INSERT INTO ORDERS (ordernum, ordertime, peoplecount, orderdesc, paytype, orderstatus,
productid, memberid) VALUES ('54351', 20180302120000, 2, '没什么', 0, 1, 1,1);
INSERT INTO ORDERS (ordernum, ordertime, peoplecount, orderdesc, paytype, orderstatus,
productid, memberid) VALUES ('14321', 20180302120000, 2, '没什么', 0, 1, 1,1);
INSERT INTO ORDERS (ordernum, ordertime, peoplecount, orderdesc, paytype, orderstatus,
productid, memberid) VALUES ('34321', 20180302120000, 2, '没什么', 0, 1, 1,1);
INSERT INTO ORDERS (ordernum, ordertime, peoplecount, orderdesc, paytype, orderstatus,
productid, memberid) VALUES ('84321', 20180302120000, 2, '没什么', 0, 1, 2,1);
INSERT INTO ORDERS (ordernum, ordertime, peoplecount, orderdesc, paytype, orderstatus,
productid, memberid) VALUES ('13321', 20180302120000, 2, '没什么', 0, 1, 2,1);
INSERT INTO ORDERS (ordernum, ordertime, peoplecount, orderdesc, paytype, orderstatus,
productid, memberid) VALUES ('42321', 20180302120000, 2, '没什么', 0, 1, 1,2);
INSERT INTO ORDERS (ordernum, ordertime,