当前位置: 移动技术网 > IT编程>数据库>Mysql > MySQL单表查询

MySQL单表查询

2018年06月10日  | 移动技术网IT编程  | 我要评论

单表查询

1、查询所有:

select * from 表名;

2、查询选中字段数据:

select 字段名 from 表名;

3、查询指定条件下的数据:

select 字段名 from 表名 where 条件(例id>3);

4、查询后为字段取别名 as:

select 原名 as 更改名 from 表名;

5、模糊查询 like:

select *from 表名 where 字段名 like 该字段里的其中一个字符(例‘小%’,则查询出该字段里所有以小字开头的数据,‘%百分号代表后面多个’,‘_下划线代表一个’)

6、排序 order by:

select * from 表名 order by 字段名;(默认升序:asc)

select * from 表名 order by 字段名 desc;(降序:desc)

7、限制显示数据的数量 limit :

select * from 表名 order by 字段名 limit 2;# 以字段名的升序取两条数据,2为限制两条数据

select * from 表名 order by 字段名 limit 2,2;

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网