創(chuàng)建購物車
create table carts(
id int unsingned primary key auto_INCREMENT,
customer_id int unsigned not null
)charset utf8;
創(chuàng)建購物項(xiàng)表
create table cart_detail(
id int unsigned primary key auto_increment,
cart_id int unsigned not null,
good_id int unsigned not null,
quantity int unsigned not null comment '數(shù)量',
price decimal(10,2) not null comment '價(jià)格'
)charset utf8;
插入
insert into customers values(0,'東哥','山東','123456');
insert into customers values(0,'源哥','山東','654321');
insert into? carts values (0,2);
insert into cart_detall values(0,1,22,,4999x);
select * from cart_detall
select * from carts as c,cart_detail as d where c.cusromer_id = 2 and d.good_id = 22 ;? ?#有
select * from carts as c,cart_detail as d where c.cusromer_id = 2 and d.good_id = 21 ;? ?#無