sql常用查询语句
2014-01-25 16:08
357 查看
--1、一般查询语句
select colunm from table;
--2、过滤重复
select distinct column from table;
--3、增加选择条件
select column from table where condition
where and
where or
where between and
where in()
--4、模糊查询
select column from table like keywords like %_;
--5、多表查询
select table1.colunm, table2.colunm from table1,table2
where condition
--二、组函数(avg()、sum())\分组函数(group by)\排序(order by)bbb
--1、组函数 avg\sum\max\min\count
--2、分组函数
group by column
having condition
select avg(salary),department_id from employees
group by department_id
having avg(salary)>1000;
--3、排序
order by
select last_name,salary from employees order by salary
select last_name,hire_date from employees order by hire_date desc;
--4、子查询
select * from employees where salary =
(select salary from employees where last_name ='joll');
select * from employees where salary =(select max(salary) from employees);
select * from employees where salary in ();
select colunm from table;
--2、过滤重复
select distinct column from table;
--3、增加选择条件
select column from table where condition
where and
where or
where between and
where in()
--4、模糊查询
select column from table like keywords like %_;
--5、多表查询
select table1.colunm, table2.colunm from table1,table2
where condition
--二、组函数(avg()、sum())\分组函数(group by)\排序(order by)bbb
--1、组函数 avg\sum\max\min\count
--2、分组函数
group by column
having condition
select avg(salary),department_id from employees
group by department_id
having avg(salary)>1000;
--3、排序
order by
select last_name,salary from employees order by salary
select last_name,hire_date from employees order by hire_date desc;
--4、子查询
select * from employees where salary =
(select salary from employees where last_name ='joll');
select * from employees where salary =(select max(salary) from employees);
select * from employees where salary in ();
相关文章推荐
- 常用SQL语句查询分享
- 常用sql查询语句
- 浅谈MySQL中优化sql语句查询常用的30种方法
- T-SQL常用查询语句
- 浅谈MySQL中优化sql语句查询常用的30种方法
- MySQL中优化sql语句查询常用的30种方法
- 常用SQL查询语句
- 常用SQL与ACCESS数据查询语句的区别
- SQL常用查询语句
- [转] 常用SQL查询语句
- 浅谈MySQL中优化sql语句查询常用的30种方法
- 常用SQl 查询语句
- 浅谈MySQL中优化sql语句查询常用的30种方法
- 常用sql查询语句
- 一些常用的SQL查询语句
- sql:常用sql语句整理二 (连接查询)
- 初学sql时常用查询语句
- 比较常用的sql 查询语句
- 常用SQL查询语句
- 浅谈MySQL中优化sql语句查询常用的30种方法