您的位置:首页 > 其它

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 (左右关联)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: