在线帮助 ICP备案 合作机构 我要订制
 
 7×24客服热线:13663712063
您的位置:首页  技术支持 本页的SQL例句全部懂了,你的数据库开发所需知识就够用了
       越辰家政管理软件
       越辰空调售后管理软件
       越辰图书销售管理软件
       越辰物业管理软件
       越辰茶楼管理软件
       越辰幼儿园管理软件
       越辰餐饮管理软件
       越辰病历管理系统
       越辰洗浴管理软件
       越辰住院管理系统
       越辰超市管理系统
  

本页的SQL例句全部懂了,你的数据库开发所需知识就够用了

来源:yocin  时间:2012-2-17 14:20:01  栏目:技术支持  点击率:4815

--======子查询============
--在一个SQL语句中镶入另一个SQL语句教镶套查询,而被镶入的这个SQL语句就被江湖人称子查询。是处理多表操作的附加方法
--子查询也称内部查询,而包含子查询的Select语句被诚为外部查询,子查询自身可以包括一个或者多个子查询,也可以镶套任意数量的子查询

--使用in的子查询
select * from studio where cl_id in (select cl_id from class where cl_id>2)
--使用 not in
select * from studio where cl_id not in (select cl_id from class where cl_id>2)


--使用比较运算符的子查询      --  any 表示子查询中任意的值     all 表示子查询中的每个值
--使用any
select * from class where cl_id>any(select cl_id from studio where st_age>30)
--使用all
select * from class where cl_id>all(select cl_id from studio where st_age>30)


--============一个分页的SQL语句========
select top 3 * from studio
where st_id>all(select top 3 st_id from studio order by st_id)
order by st_id




--使用 exists ,该关键字引入一个子查询的时候基本上是对数据进行一次是否存在的测试
--我们查询那些人所在的班级是编号为 1 的
select * from studio where exists(select cl_id from class where studio.cl_id=class.cl_id and class.cl_id=1) 
--使用 not exists
select * from studio where not exists(select * from class where studio.cl_id=class.cl_id and class.cl_id=1) order by st_id


--基于查询生成新的表
select st_name into class_3 from studio where cl_id=3 

--将数据批量插入一个表中
insert into class_3 select st_name from studio where cl_id=4


  【 1 】  【 2 】  【 3 】  【 4 】  【 5 】 
Copyright ◎2008-2018郑州越辰科技有限公司 版权所有 网站地图
地址:中国·河南郑州市文化路交北环路北晨e时代B座505室 
电话:0371-63399049 13663712063 备案号:豫ICP备19031456号
我们专注于 软件开发| 网站制作  返回欢迎页 
  
点击这里给我发消息 越辰业务
点击这里给我发消息 越辰业务
点击这里给我发消息 越辰代理
点击这里给我发消息 越辰技术
 ,页面执行时间:16.602毫秒        
up close

返回顶部

越辰科技微信
微信扫一扫