select 常用语句
2008-05-07 10:27
323 查看
select 用法 select * from test (显示所以字段)
select count(*) from test (统计test表中的记录)
select id, name from test(显示部分字段)
select id 学号, name 姓名 from test (取别名)
select * from test where id='007'(显示直到信息)
select * from test where name in=('007','008') (in 用法)
select a.id1,a.name2 from test1 a where not exists (select * from test2 b where b.name2=a.name2) (exists用法)
select distinct name from test (名字不重复)
select * from test order by id desc(按id升序)
select * from test order by id asc (默认)
select * from test order by 2 desc (2 表示第2列)
select * from TBL_TEST start with id=1 connect by prior id = pid (树表查询)
select * from (select * from test order by num asc ) where rownum <3 (显示表中前三条 )
select id,name from test group by id,name (按id,name分组)
select id,name from test group by 1,2 (按id,name分组)
select num,name from test group by num,name having count(*)>1
select id table a,(select id,name count(*) from table group by id,name having count(1)>1) b where b.id=b.id and a.name=b.rg group by id,rg (显示重复记录)
select t1.id id,ti.name name,t2.oder oder1,t3.oder oder2 from test1 t1,test2 t2,test3 t3 where t1.name(+)=t2.name t1.name(+)=t3.name (左右关联)
select count(*) from test (统计test表中的记录)
select id, name from test(显示部分字段)
select id 学号, name 姓名 from test (取别名)
select * from test where id='007'(显示直到信息)
select * from test where name in=('007','008') (in 用法)
select a.id1,a.name2 from test1 a where not exists (select * from test2 b where b.name2=a.name2) (exists用法)
select distinct name from test (名字不重复)
select * from test order by id desc(按id升序)
select * from test order by id asc (默认)
select * from test order by 2 desc (2 表示第2列)
select * from TBL_TEST start with id=1 connect by prior id = pid (树表查询)
select * from (select * from test order by num asc ) where rownum <3 (显示表中前三条 )
select id,name from test group by id,name (按id,name分组)
select id,name from test group by 1,2 (按id,name分组)
select num,name from test group by num,name having count(*)>1
select id table a,(select id,name count(*) from table group by id,name having count(1)>1) b where b.id=b.id and a.name=b.rg group by id,rg (显示重复记录)
select t1.id id,ti.name name,t2.oder oder1,t3.oder oder2 from test1 t1,test2 t2,test3 t3 where t1.name(+)=t2.name t1.name(+)=t3.name (左右关联)
相关文章推荐
- DB2数据库(Database)常用SQL查询(SELECT语句)命令
- 第二章 Select语句:常用元素
- 常用语句(四)select top ... ... from ... where ... not in(select top ... ... from ...)、AVG()
- select 常用语句总结
- mysql常用语句——结合select的insert语句
- SELECT语句常用字句的用法
- mysql中常用的select语句记录
- 常用Select语句
- mysql常用语句——结合select的insert语句
- Mysql常用查询语句
- 常用SQL语句
- MyBatis常用SQL语句整理笔记
- 跟我学SQL:(二)SELECT语句选项
- select查询语句
- Mysql常用语句(记一下,免得忘)
- 一个SELECT语句引发的迭代(SELECT @local_variable = expression 的妙用)
- 8个SQL语句常用优化技巧
- MYSQL的常用命令和增删改查语句和数据类型
- oracle select into 动态语句
- 常用的SQL语句