day 34 作业

   # 创建表
   create table oldboy(
   id int unsigned auto_increment primary key,
   name char(10) not null default 'sb',
   age int not null default 0,
   status enum('teacher','student'),
   wage int not null default 0
   )charset=utf8;
   
   # 插入值
   insert into oldboy (name,age,status,wage) values
   ('nick',25,'teacher',10000),
   ('tank',27,'teacher',5000),
   ('jin_sb',33,'teacher',250),
   ('zekai',31,'teacher',20000),
   ('logan',23,'student',0),
   ('dsb',35,'student',0);
   
   # 查看岗位是teacher的员工姓名、年龄
   select name,age from oldboy where status = 'teacher';
   # 查看岗位是teacher且年龄大于30岁的员工姓名、年龄
   select name,age from oldboy where status = 'teacher' and age>30;
   # 查看岗位是teacher且薪资在9000-1000范围内的员工姓名、年龄、薪资
   select name,age,wage from oldboy where status = 'teacher' and wage between 1000 and 9000;
   # 查看岗位描述不为NULL的员工信息
   select * from oldboy where status not is 'null';
   # 查看岗位是teacher且薪资是10000或9000或30000的员工姓名、年龄、薪资
   select name,age,wage from oldboy where status = 'teacher' and (wage between 1000 and 9000 or wage = 3000);
   # 查看岗位是teacher且薪资不是10000或9000或30000的员工姓名、年龄、薪资
   select name,age,wage from oldboy where status = 'teacher' and wage not in (9000,10000,30000);
   # 查看岗位是teacher且名字是jin开头的员工姓名、年薪
   select name,wage*12 as y_wage from oldboy where status = 'teacher' and name like 'jin%';
原文地址:https://www.cnblogs.com/luocongyu/p/11761215.html