mysql单表多条件查询_mysql之单表条件查询

create table staff_info(

id int primary key auto_increment,

name varchar(32) not null,

age int(3) unsigned not null,

sex enum('male','female') not null default 'male',

duty varchar(50) not null,

salary decimal(15,2) not null,

remark varchar(100)

) charset=utf8;

insert into staff_info(name,age,sex,duty,salary,remark) values

('张三',18,'male','programmer',12000.27,'我高新,我骄傲!'),

('zhang',88,'male','charger',80000084,'缺钱,冲我来!'),

('wang',24,'male','teacher',19999.990,'我可不是一朵娇花,不用怜惜我!'),

('刘二丫',36,'female','cooker',6000.87,null),

('李四五',47,'male','teacher',15550,null),

('echo',18,'male','teacher',20000,'走到哪里,我都要问别人:睡我不?'),

('翠花',17,'female','seller',7500.27,null),

('朵朵',23,'female','形象代言',12300.556,null);

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

select name,age from staff_info where duty='teacher';

2.查看岗位是teacher且年龄大于30岁的员工姓名、年龄;

select name,age from staff_info where age>30 and duty='teacher';

3.查看岗位是teacher且薪资在9000-1000范围内的员工姓名、年龄、薪资

select name,age,salary from staff_info where duty='teacher' and salary between 9000 and 10000;

4.查看岗位描述不为NULL的员工信息

select * from staff_info where remark !='null';

5.查看岗位是teacher且薪资是10000或9000或30000的员工姓名、年龄、薪资

select name,age,salary from staff_info where duty='teacher' and salary in(10000,9000,30000);

6.查看岗位是teacher且薪资不是10000或9000或30000的员工姓名、年龄、薪资

select name,age,salary from staff_info where duty='teacher' and salary not in(10000,9000,30000);

7.查看岗位是teacher且名字是e开头的员工姓名、年薪

select name,salary from staff_info where name like 'e%';

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值