您的位置:首页 > 博客中心 > 数据库 >

SQL Server 基础 05 多链表查询和子查询

时间:2022-03-10 17:06

                              

                                                                 连接查询

 

值得注意的是:字段前必须加表名,以便混淆

 

gxlsystem.com,布布扣

使用where后

gxlsystem.com,布布扣

 

使用逻辑运算符 and

gxlsystem.com,布布扣

/**/  相比上面的 where + and 更简单

 

 

                                                    高级连接查询

       // 这里只是粗略的概括下,来自 书本:《21 天学通SQL Server》  第11章 P226 

1、自动连接查询

              /**/ 

               select 表名1.* from 表名1,表名2 where 表名1.字段=表名2.字段 and 表名2.字段=‘字段值’

2、内连接查询

               等值连接    : 表名1.*=表名2.*

               自然连接    : select 后面不使用* ,而是字段名

               不等值连接 : 由 >、>=、< 、<= 、<>  、between . . . 查询某些范围内的值

3、左外连接查询

               语法         :select * from 表名1 left outer join 表名2 on 表名1.字段=表名2.字段

4、右外连接查询

               语法         :select * from 表名1 right outer join 表名2 on 表名1.字段=表名2.字段

5、全外连接查询

               语法         :select * from 表名1 full outer join 表名2 on 表名1.字段=表名2.字段

6、交叉连接查询

               语法         :select * from 表名1 cross join 表名2

 

SQL Server 基础 05 多链表查询和子查询,布布扣,bubuko.com

热门排行

今日推荐

热门手游