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
语法:
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