注册 登录
编程论坛 SQL Server论坛

求助:有关exists的问题

nixiao311 发布于 2008-04-13 12:23, 1302 次点击
我刚刚接触数据库,发现exists语句很多情况下是可以替换的,想请问一下exists语句什么情况下是必须要有的,还是所有情况都可以用嵌套替换。 请高人指点,非常感谢!
8 回复
#2
wuwei82008-04-14 16:19
回复 1# 的帖子
exists一般情况下是在双重否定的时候用的比较多,因为那样做比较的方便。
#3
makebest2008-04-14 19:08
我觉得EXISTS语句在一对多的情况下取一比较好,不取多的那边,只判断有无
#4
we9212008-04-14 19:10
我也是刚接触SQL
exists 好象是判断是否存在的
#5
nixiao3112008-04-17 17:18
回复 2# 的帖子
非常感谢!
#6
nixiao3112008-04-17 17:19
回复 3# 的帖子
非常感谢!
#7
needtoaide2008-04-17 17:57
求助:有关索引名为问题
创建一个基于STU数据库AUTHORS表的视图AU1,然后用CREATE INDEX语句在AU_iname 和au_fname列上创建一个名为au1_index的唯一的聚集索引。请你们帮我从USE STU这句开始翻译。
   
  先在STU数据库中创建一个名为AUTHORS索引代码如下
   create table stu.dbo.authors
 (
au_id varchar(11) not null,
au_iname varchar(40) not null,
au_fname varchar(20) not null,
phone char(12),
address varchar(40),
city varchar(20),
state char(5),
contract bit not null
)
go


    use stu
go
--create view.
create view au1
with schemabinding
as
select au_id,au_iname,au_fname,adress,city,state
from dbo.authors
where state='ca'
go
--create index on the view.

cteate unique clustered index au1_index
on au1(au_iname.au_fname)
go
#8
needtoaide2008-04-17 17:59
求助:有关索引名为问题
创建一个基于STU数据库AUTHORS表的视图AU1,然后用CREATE INDEX语句在AU_iname 和au_fname列上创建一个名为au1_index的唯一的聚集索引。请你们帮我从USE STU这句开始翻译。
   
  先在STU数据库中创建一个名为AUTHORS索引代码如下
   create table stu.dbo.authors
 (
au_id varchar(11) not null,
au_iname varchar(40) not null,
au_fname varchar(20) not null,
phone char(12),
address varchar(40),
city varchar(20),
state char(5),
contract bit not null
)
go


    use stu
go
--create view.
create view au1
with schemabinding
as
select au_id,au_iname,au_fname,adress,city,state
from dbo.authors
where state='ca'
go
--create index on the view.

cteate unique clustered index au1_index
on au1(au_iname.au_fname)
go
#9
lff6422008-04-25 16:36
EXISTS返回的是一个布尔值,当你需要的只是真假的时候,你可以使用EXISTS
1