mysql>select*from student where id=3;+----+-------+-----+-----+------+-------+-------------+-----+| id | sname | sex | age | team | score | phone | fun |+----+-------+-----+-----+------+-------+-------------+-----+|3| 李四 | 男 |21| 学生 |88.00|17777119988|1|+----+-------+-----+-----+------+-------+-------------+-----+1rowinset
mysql>select*from student where id=4;+----+-------+-----+-----+------+-------+-------------+-----+| id | sname | sex | age | team | score | phone | fun |+----+-------+-----+-----+------+-------+-------------+-----+|4| 王五 | 女 |20| 学生 |99.00|17777112244|1|+----+-------+-----+-----+------+-------+-------------+-----+1rowinset
mysql>select*from student where age =22and sex ='女';+----+-------+-----+-----+------+-------+-------------+-----+| id | sname | sex | age | team | score | phone | fun |+----+-------+-----+-----+------+-------+-------------+-----+|6| 大黄 | 女 |22| 学生 |77.00|17777114444|3|+----+-------+-----+-----+------+-------+-------------+-----+1rowinset
mysql>select*from student where age =22or sex ='女';+----+-------+-----+-----+------+-------+-------------+-----+| id | sname | sex | age | team | score | phone | fun |+----+-------+-----+-----+------+-------+-------------+-----+|1| 张三 | 男 |22| 学生 |95.00|17777118877|0||4| 王五 | 女 |20| 学生 |99.00|17777112244|1||6| 大黄 | 女 |22| 学生 |77.00|17777114444|3|+----+-------+-----+-----+------+-------+-------------+-----+3rowsinset
查询数据的时,指定条件的范围性
mysql>select*from student where sex='男'and score>90;+----+-------+-----+-----+------+-------+-------------+-----+| id | sname | sex | age | team | score | phone | fun |+----+-------+-----+-----+------+-------+-------------+-----+|1| 张三 | 男 |22| 学生 |95.00|17777118877|0|+----+-------+-----+-----+------+-------+-------------+-----+1rowinset
mysql>select*from student where score<80;+----+--------+-----+-----+------+-------+-------------+-----+| id | sname | sex | age | team | score | phone | fun |+----+--------+-----+-----+------+-------+-------------+-----+|5| 赵六 | 男 |23| 学生 |59.00|17777114411|1||6| 大黄 | 女 |22| 学生 |77.00|17777114444|3||7| 李华 | 男 |25| 学生 |49.00|17777113333|4||8| 孙笑川 | 男 |26| 学生 |60.00|17777113314|5|+----+--------+-----+-----+------+-------+-------------+-----+4rowsinset
模糊查询 like ,‘T%’ 首位字符 ,‘%T’ 末尾字符 ,‘%T%’ 包含字符 ‘_’ 代表了一个字符
mysql>select*from student where sname like'大_';+----+-------+-----+-----+------+-------+-------------+-----+| id | sname | sex | age | team | score | phone | fun |+----+-------+-----+-----+------+-------+-------------+-----+|6| 大黄 | 女 |22| 学生 |77.00|17777114444|3|+----+-------+-----+-----+------+-------+-------------+-----+1rowinset
mysql>select*from student where sname like'孙_%';+----+--------+-----+-----+------+-------+-------------+-----+| id | sname | sex | age | team | score | phone | fun |+----+--------+-----+-----+------+-------+-------------+-----+|8| 孙笑川 | 男 |26| 学生 |60.00|17777113314|5|+----+--------+-----+-----+------+-------+-------------+-----+1rowinset
排序
查询同时进行排序 order by 字段 desc (降序) , order by 字段 asc(升序 默认)