创建购物车
create table carts(
id int unsingned primary key auto_INCREMENT,
customer_id int unsigned not null
)charset utf8;
创建购物项表
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 '数量',
price decimal(10,2) not null comment '价格'
)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 ; #无