关于查询顺序

发布时间:2024-11-23 01:16

使用平板电脑的序列号查询:在设备设置-关于本机中查找,然后在厂商网站输入查询真伪。 #生活技巧# #数码产品使用技巧# #电子设备防伪知识#

关于查询顺序

最新推荐文章于 2023-11-30 21:41:39 发布

claro 于 2009-02-09 09:34:00 发布

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

/*--网上找一些有趣的题目,做为新生的培训题目。
--select left('claro',2) 2009-01-16 23:56:35.903 整理于西安
--Microsoft SQL Server 2005 - 9.00.3042.00
-- (Intel X86)   Feb  9 2007 22:47:07   Copyright (c) 1988-2005
--Microsoft Corporation  Express Edition on Windows NT 5.1 (Build 2600: Service Pack 3)

有两表a和b,前两字段完全相同:(id int,name varchar(10)...),都有下面的数据(当然还有其它字段,这里不列出来了):
id          name    
----------- ----------
1          a        
2          b        
3          c        

以下的查询语句,你知道它的运行结果吗?:
1.
select * from a left join b on a.id=b.id where a.id=1
2.
select * from a left join b on a.id=b.id and a.id=1
3.
select * from a left join b on a.id=b.id and b.id=1
4.
select * from a left join b on a.id=1
5.
select * from a left join b on a.id=1 where a.id=1
*/
use tempdb
if object_id('a') is not NULL
    drop table a
go
create table a (id int identity, [name] varchar(10) )
go
insert into a
select 'a' union all
select 'b' union all
select 'c' union all
select 'd'
go
if object_id('b') is not NULL
    drop table b
go
create table b (id int identity, [name] varchar(10) )
go
insert into b
select 'a' union all
select 'b' union all
select 'd'

--1.
select * from a left join b on a.id=b.id where a.id=1
/*
id    name    id    name
1    a    1    a
*/
--2.
select * from a left join b on a.id=b.id and a.id=1
/*
id    name    id    name
1    a    1    a
2    b    NULL    NULL
3    c    NULL    NULL
4    d    NULL    NULL
*/
--3.
select * from a left join b on a.id=b.id and b.id=1
/*
id    name    id    name
1    a    1    a
2    b    NULL    NULL
3    c    NULL    NULL
4    d    NULL    NULL
*/
--4.
select * from a left join b on a.id=1
/*
id    name    id    name
1    a    1    a
1    a    2    b
1    a    3    d
2    b    NULL    NULL
3    c    NULL    NULL
4    d    NULL    NULL
*/
--5.
select * from a left join b on a.id=1 where a.id=1
/*
id    name    id    name
1    a    1    a
1    a    2    b
1    a    3    d
*/
--6.
select * from a cross join b where a.id=1
/*
id    name    id    name
1    a    1    a
1    a    2    b
1    a    3    d
*/

网址:关于查询顺序 https://www.yuejiaxmz.com/news/view/201069

相关内容

在线购物系统顺序图
家庭关系的顺序对了,生活就顺了
清洁用品摆放顺序()
灯具安装的顺序
便民生活查询
12333社保查询电话
深度清洁的一般顺序是()
关于心理咨询的科普
关于如何做好与家长沟通接待 工作咨询的
家庭大扫除的顺序

随便看看