orcle学习之路第二天

73人阅读 评论(0)

1.Order by:
select * from zybrxx order by zyh asc
Select * from zybrxx order by zyh desc
select zyh, brxm,bqh from zybrxx order by bqh,zyh
select zyh, brxm,bqh from zybrxx order by zyh,bqh
select zyh, brxm,bqh from zybrxx order by bqh asc,zyh desc
select * from zybq order by dm desc ,lc asc
2.Group by:select count(*) from zybrxx group by bqh
SQL 无法把正常的列和汇总函数结合在一起
select count(*),zyh from zybrxx group by bqh//会提示错误

3.Having:select sum(zfze) from zybrxx group by zfze having sum(zfze)>0

4.在一个sql中使用多个表：交叉联合select * from ksmc,zybq
select no,xh,dm from ksmc,zybq
5.等值联合：select * from zybrxx a,ksmc b where b.no = a.ksbh and a.ksbh<2
6.不等值联合：select * from zybrxx a,ksmc b where b.no > a.ksbh
7.select * from zybrxx a join ksmc b on a.ksbh=b.no那个表在前就以那个表为主
8.右联接：select * from ksmc b right outer join zybrxx a on a.ksbh =b.no
9.左联接：select * from ksmc b left outer join zybrxx a on a.ksbh =b.no

10.select * from zybrxx a,ksmc b where a.ksbh=(select no from ksmc where mc=’内科’ ) and a.ksbh =b.no
11.子查询的嵌套：select * from zybrxx a,ksmc b where a.ksbh=(select no from ksmc where mc=(select mc from ksmc where no=1 )) and a.ksbh =b.no

12.插入语句Insert values：insert into zybq(dm,mc,qx,dnfykf,bqfl,lc,srm1,srm2,cwyybz) values(‘12’,’病区2’,’**’,’02’,0,666,’88BQ’,’88UA’,’Y’)

Insert select:insert into new_table select * from zybq//可完成对表的备份
13.Update:update zybq set mc=’病区2眼科’ where dm=’15’

14.Delete:delete from zybq where dm=’15’

0
0

* 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场
个人资料
• 访问：5479次
• 积分：242
• 等级：
• 排名：千里之外
• 原创：18篇
• 转载：4篇
• 译文：1篇
• 评论：2条
文章分类
评论排行
最新评论