parent
ea0380a96d
commit
af44fc3b86
@ -0,0 +1,89 @@
|
||||
create database cs;
|
||||
|
||||
use cs;
|
||||
|
||||
create table ygxx( #员工信息表
|
||||
Ygbh char(8) not null primary key, #员工编号
|
||||
Name varchar(8) not null, #姓名
|
||||
Sex Char(2) not null, #性别
|
||||
Zw varchar(10) not null, #职务
|
||||
Kl varchar(20) not null, #口令
|
||||
Qxjb char(1) not null, #权限级别
|
||||
Sfzh Char(18), #身份证号
|
||||
ssbmbh char(4) #所属部门编号
|
||||
)engine = InnoDB default charset=utf8;
|
||||
|
||||
|
||||
create table bmxx(
|
||||
bmbh char(8) NOT NULL primary key,
|
||||
bmmc varchar(4) not null
|
||||
)engine=InnoDB default charset=utf8;
|
||||
|
||||
create table spxx(
|
||||
Spbh char(8) not null primary key,
|
||||
Spmc varchar(20) not null,
|
||||
Sslb char(8) not null,
|
||||
Jg FLOAT(10,2) not null,
|
||||
sl int(4) not null
|
||||
)engine=InnoDB default charset=utf8;
|
||||
|
||||
create table supplier(
|
||||
Gysbh Char(8) not null primary key,
|
||||
Gysmc varchar(8) not null,
|
||||
Dz varchar(20) not null,
|
||||
Yzbm char(6) not null,
|
||||
Dhhm varchar(15) not null,
|
||||
Sh varchar(3) not null,
|
||||
Yhzh varchar(20) not null,
|
||||
Khyh varchar(8) not null,
|
||||
Lxr varchar(8) not null,
|
||||
beizhu varchar(16)
|
||||
)engine=InnoDB default charset=utf8;
|
||||
|
||||
SET SQL_SAFE_UPDATES = 0;
|
||||
|
||||
|
||||
#添加数据
|
||||
insert into ygxx(Ygbh,Name,Sex,Zw,Kl,QXjb,ssbmbh)values('10000001','张利','男','主管','123','5','1001');
|
||||
insert into ygxx(Ygbh,Name,Sex,Zw,Kl,QXjb,ssbmbh)values('10000002','刘程','男','副主管','123','4','1002');
|
||||
insert into ygxx values('10000003','张三','男','员工','12','1',null,'1003'),
|
||||
('10000004','李四','男','员工','12','1',null,'1004');
|
||||
insert into bmxx values('1001','业务'),('1002','技术'),('1003','售后'),('1004','管理');
|
||||
insert into spxx values('10000001','空调','电器','1500','10'),('10000002','书包','文具','100','20'),
|
||||
('10000003','卷纸','日用品','30','50'),('10000004','铅笔','文具','10','100'),
|
||||
('10000005','橡皮','文具','5','1000'),('10000006','风扇','电器','1000','10'),
|
||||
('10000007','水杯','日用品','20','100'),('10000008','牙刷','日用品','20','100');
|
||||
|
||||
create table spsupp
|
||||
(ssbh char(4) primary key, # 供应商品编号
|
||||
spbh char(8) not null, # 商品编号
|
||||
gysbh char(80) not null, # 供应商编号
|
||||
price float, # 供应价格
|
||||
sl int, #供应数量
|
||||
sj datetime ); #供应时间
|
||||
insert into supplier values
|
||||
('10000001','格力公司','佛山','528200','07576326535','dw','330625325','工商银行','jary',null), ('10000002','美的公司','佛山','528201','07576326536','dt','330625326','工商银行','jarat',null),
|
||||
('10000003','宝洁公司','广州','520660','0206326538','dp','330625328','工商银行','teey',null);
|
||||
|
||||
insert into spsupp values
|
||||
('1001','10000001','10000001',2500,300,'2020-10-1'),
|
||||
('1002','10000001','10000002',2380,500,'2020-10-2'),
|
||||
('1003','10000003','10000003',30,1500,'2020-10-3');
|
||||
|
||||
select * from bmxx;
|
||||
select * from spxx;
|
||||
select * from supplier;
|
||||
select * from ygxx;
|
||||
select * from spsupp;
|
||||
|
||||
#1
|
||||
select Ygbh,Name,Zw,Qxjb from Ygxx where ssbmbh=(select bmbh from bmxx where bmmc='业务');
|
||||
|
||||
#2
|
||||
select Gysbh,Gysmc,Dz,Dhhm from supplier where Gysbh=(select Spbh from spxx where Spmc='空调');
|
||||
|
||||
#3
|
||||
select spxx.spmc,spxx.sslb,supplier.gysmc from (spsupp inner join spxx on spsupp.spbh=spxx.spbh) inner join supplier on spsupp.gysbh=supplier.gysbh
|
||||
where spsupp.sj>='2020-10-01 00:00:00' and spsupp.sj<'2020-10-03 00:00:00';
|
||||
|
||||
#4
|
||||
Loading…
Reference in new issue