Sql server® 2012 t-sql fundamentals



Download 10,93 Mb.
Pdf ko'rish
bet244/443
Sana26.01.2022
Hajmi10,93 Mb.
#411755
1   ...   240   241   242   243   244   245   246   247   ...   443
Bog'liq
BookSQL

The 

UNION ALL

 Multiset Operator

The UNION ALL multiset operator returns all rows that appear in any of the input multisets resulting 

from the two input queries, without really comparing rows and without eliminating duplicates. As-

suming that Query1 returns m rows and Query2 returns n rows, Query1 UNION ALL Query2 returns 

m + n rows. 

www.it-ebooks.info




 

CHAPTER 6

 

Set Operators



 

 193

For example, the following code uses the UNION ALL operator to unify employee locations and 

customer locations.

USE TSQL2012; 

 

SELECT country, region, city FROM HR.Employees 



UNION ALL 

SELECT country, region, city FROM Sales.Customers;

The result has 100 rows—9 from the Employees table and 91 from the Customers table—and is 

shown here in abbreviated form:

country         region          city 

--------------- --------------- --------------- 

USA             WA              Seattle 

USA             WA              Tacoma 

USA             WA              Kirkland 

USA             WA              Redmond 

UK              NULL            London 

UK              NULL            London 

UK              NULL            London 

... 


Finland         NULL            Oulu 

Brazil          SP              Resende 

USA             WA              Seattle 

Finland         NULL            Helsinki 

Poland          NULL            Warszawa 

 

(100 row(s) affected)



Because UNION ALL doesn’t eliminate duplicates, the result is a multiset and not a set. The same 

row can appear multiple times in the result, as is the case with (UK, NULL, London) in the result of this 

query.


Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   240   241   242   243   244   245   246   247   ...   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