Sql server® 2012 t-sql fundamentals



Download 10,93 Mb.
Pdf ko'rish
bet193/443
Sana26.01.2022
Hajmi10,93 Mb.
#411755
1   ...   189   190   191   192   193   194   195   196   ...   443
Bog'liq
BookSQL

The 

EXISTS

 predicate

T-SQL supports a predicate called EXISTS that accepts a subquery as input and returns TRUE if the 

subquery returns any rows and FALSE otherwise. For example, the following query returns customers 

from Spain who placed orders.

SELECT custid, companyname 

FROM Sales.Customers AS C 

WHERE country = N'Spain' 

  AND EXISTS 

    (SELECT * FROM Sales.Orders AS O 

     WHERE O.custid = 



C.custid

);

The outer query against the Customers table filters only customers from Spain for whom the EXISTS 



predicate returns TRUE. The EXISTS predicate returns TRUE if the current customer has related orders 

in the Orders table. 

One of the benefits of using the EXISTS predicate is that it allows you to intuitively phrase English-

like queries. For example, this query can be read just as you would say it in ordinary English: select the 

customer ID and company name attributes from the Customers table, where the country is equal to 

Spain, and at least one order exists in the Orders table with the same customer ID as the customer’s 

customer ID.

www.it-ebooks.info





Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   189   190   191   192   193   194   195   196   ...   443




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish