1、准备工作
在MySQL数据库中创建两张表balance(余额表)和customer(客户表)并插入数据。
create table customer(
id int(10) primary key,
name char(20) not null,
role char(20) not null,
phone char(20) not null,
sex char(10) not null,
address char(50) not null
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
#外键为customerId
create table balance(
id int(10) primary key,
customerId int(10) not null,
balance DECIMAL(10,2),
foreign key(customerId) references customer(id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
向客户表和余额表中各插入3条数据。
insert into customer values(0001,"xiaoming",'vip1','12566666','male','江宁区888号');
insert into customer values(0002,"xiaohong",'vip10','15209336760','male','建邺区888号');
insert into customer values(0003,"xiaocui&