当前位置:Gxlcms > 数据库问题 > SQL高级查询

SQL高级查询

时间:2021-07-01 10:21:17 帮助过:2人阅读

高级查询:

一、多表链接

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高级查询

标签:

人气教程排行