学习型 ASP/PHP/ASP.NET 主机 30元/年全能 ASP/PHP/ASP.NET 主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付
发新话题
打印

求助:有关exists的问题

求助:有关exists的问题

我刚刚接触数据库,发现exists语句很多情况下是可以替换的,想请问一下exists语句什么情况下是必须要有的,还是所有情况都可以用嵌套替换。 请高人指点,非常感谢!

TOP

回复 1# 的帖子

exists一般情况下是在双重否定的时候用的比较多,因为那样做比较的方便。

TOP

我觉得EXISTS语句在一对多的情况下取一比较好,不取多的那边,只判断有无

TOP

我也是刚接触SQL
exists 好象是判断是否存在的

TOP

回复 2# 的帖子

非常感谢!

TOP

回复 3# 的帖子

非常感谢!

TOP

求助:有关索引名为问题

创建一个基于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

TOP

求助:有关索引名为问题

创建一个基于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

TOP

EXISTS返回的是一个布尔值,当你需要的只是真假的时候,你可以使用EXISTS

TOP

发新话题