1. create table dept( did int primary key auto_increment, dname varchar(20) );
2. create table emp( id int primary key auto_increment, name varchar(10), gender char(1), salary double, join_date date, dep_id int, FOREIGN key (dep_id) REFERENCES dept(did) );
3. insert into dept (dname) values ('研发部'),('市场部'),('财务部'),('销售部');
4. insert into emp(name,gender,salary,join_date,dep_id) values ('孙悟空','男',7200,'2013-02-24',1), ('猪八戒','男',3600,'2010-12-02',2), ('唐僧','男',9000,'2008-08-08',2), ('白骨精','女',5000,'2015-10-07',3), ('蜘蛛精','女',4500,'2011-03-14',1), ('小白龙','男',2500,'2011-02-14',null);
select * from emp,dept;-- 笛卡尔积
select * from emp,dept where emp.dep_id=dept.did;-- 正确的