首页 > 数据库技术 > 详细

SQL高级查询

时间:2016-01-17 09:44:55      阅读:152      评论:0      收藏:0      [点我收藏+]

高级查询:

一、多表链接

1,普通查询

select * from 表名,表名 where 表名.列名 = 表名.列名

2,join链接

select * from 表名 join 表名 on 表名.列名 = 表名.列名

二、多表联合

select * from 表名 where 列名=‘内容‘ union select * from 表名 where 列名=‘内容‘

三、子查询(无关子查询)

select * from 表名 where 列名 = (select 列名 from 表名 where 列名=‘内容‘) 查单条数据用= !=非此条数据之外的内容

select * from 表名 where 列名 not in (select 列名 from 表名 where 列名=‘内容‘ 列名 = ‘内容‘) 查多条数据用in not就是非此类条件

四、子查询(相关子查询)

select * from 表名 定义名 where 定义名.列名<(select avg(列名)from 表名 定义名 where 定义名.列名 = 定义名.列名)

SQL高级查询

原文:http://www.cnblogs.com/liaoliao/p/5136765.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!