day 34 作业

PS C:WINDOWSsystem32> mysql -uroot -p
Enter password:
    
mysql> use feng;
Database changed 

mysql> create table infor(
    -> id int unsigned auto_increment primary key,
    -> name varchar(10) not null default 'xxx',
    -> age int not null default 0,
    -> salary decimal(10,2) not null default 0,
    -> work varchar(20) not null default 'xxx'
    -> )charset=utf8;


mysql> insert into infor (name,age,work,salary) values
    -> ('nick',22,'teacher',9999.99),
    -> ('jing',32,'teacher',10000.00),
    -> ('tank',20,'teacher',12000);

1.查看岗位是teacher的员工姓名、年龄

mysql> select name,age from infor where work='teacher';
  1. 查看岗位是teacher且年龄大于30岁的员工姓名、年龄

     select name,age from infor where work='teacher' and age>30;
    
  2. 查看岗位是teacher且薪资在9000-10000范围内的员工姓名、年龄、薪资

    mysql> select name,age,salary from infor where work='teacher' and salary between 9000 and 10000;
    
  3. 查看岗位描述不为NULL的员工信息

    mysql> select * from infor where work is not null;
    
  4. 查看岗位是teacher且薪资是10000或9000或30000的员工姓名、年龄、薪资

    mysql> select name,age,salary from infor where salary=10000 or salary=9000 or salary=30000;
    
  5. 查看岗位是teacher且薪资不是10000或9000或30000的员工姓名、年龄、薪资

    mysql> select name,age,salary from infor where salary!=10000 and salary!=9000 and salary!=30000;
    
  6. 查看岗位是teacher且名字是jin开头的员工姓名、年薪

mysql> select name,salary*12 as year_salary from infor where name like 'jin%';
原文地址:https://www.cnblogs.com/zqfzqf/p/11760899.html