MySQL学习笔记——条件查询

1、普通条件查询
语法:
select col_list from table_name
[where condition_expression]
示例:查询QQ号为12301的玩家信息
select * from users where user_QQ='12301'
示例:查询分数大于2500分的数据
select * from scores where score>2500
示例:查询游戏编号为1且分数大于4000的分数xinxi
select * from scores
where gno=1 and score>4000
2、比较运算符
等于  =
不等于  <>
大于  >
小于  <
小于等于 <=
大于等于 >=
3、逻辑运算符
并且 AND
或者 OR
非  NOT
示例:查询游戏编号为1和2的分数信息
select * from scores where gno=1 or gno=2
4、模糊查询
示例:查询分数在2500(含)到3000(含)的分数信息
select * from scores
where score>=2500 and score<=3000
或者
select * from scores
where score between 2500 and 3000
示例:查询分数不在2500(含)到3000(含)的分数信息
select * from scores
where score not between 2500 and 3000
示例:查询1987年1月1日到1992年7月31日出生的玩家
select * from users
where user_birthday
between '1987-01-01' and '1992-07-31'
示例:查询所有姓孙的玩家信息
select * from users
where user_name like '孙%'
示例:查询所有非姓孙的玩家信息
select * from users
where user_name not like '孙%'
5、查询空值的运算符
示例:查询生日为null的玩家信息
select * from users where user_birthday is null
示例:查询生日不为null的玩家信息
select* from usres
where user_birthday is not null
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值