码迷,mamicode.com
首页 > 数据库 > 详细

Mysql表数据查询操作

时间:2019-09-01 12:50:24      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:group   obb   sel   avg   count   use   sele   tween   inner   

1、简单查询

select * from user;

2、NULL查询

select * from user where hobby is NULL and age is not NULL;

3、in查询

select * from user where age in('22','23','24');

4、between and查询

select * from user where age between 21 and 55;

5、or查询

select * from user where age=22 or age=23

6、order by 查询

select * from user order by age asc; 升序
select * from user order by age desc; 降序

7、group by查询

select name,sum(age) from user group by name

8、常见聚合函数

count(*)函数;
sum()函数;
avg()函数;
max()函数;

9、内连接查询

select u.id,f.name from user u inner join user f on u.id=f.id; 推荐
select u.id,f.name from user u,user f where u.id=f.id;

10、外连接查询

select u.id,f.name from user u left join user f on u.id=f.id;

11、

Mysql表数据查询操作

标签:group   obb   sel   avg   count   use   sele   tween   inner   

原文地址:https://www.cnblogs.com/feiqiangsheng/p/11441740.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!