EXISTS Operator
EXISTS operatori bir subso'rovda har qanday yozuv mavjudligini tekshirish uchun ishlatiladi.
SQL EXISTS Operatori
EXISTS operatori bir subso'rovda har qanday yozuv mavjudligini tekshirish uchun ishlatiladi.
EXISTS operatori subso'rov bir yoki bir nechta yozuv qaytarsa, TRUE qiymatini qaytaradi.
EXISTS Sintaksisi
Demo Ma'lumotlar Bazasi
Ushbu o'quv qo'llanmada Northwind namunaviy ma'lumotlar bazasidan "Products" jadvalidan bir tanlov:
ProductID | ProductName | SupplierID | CategoryID | Unit | Price |
---|---|---|---|---|---|
1 | Chais | 1 | 1 | 10 boxes x 20 bags | 18 |
2 | Chang | 1 | 1 | 24 - 12 oz bottles | 19 |
3 | Aniseed Syrup | 1 | 2 | 12 - 550 ml bottles | 10 |
4 | Chef Anton's Cajun Seasoning | 2 | 2 | 48 - 6 oz jars | 22 |
5 | Chef Anton's Gumbo Mix | 2 | 2 | 36 boxes | 21.35 |
Va "Suppliers" jadvalidan bir tanlov:
SupplierID | SupplierName | ContactName | Address | City | PostalCode | Country |
---|---|---|---|---|---|---|
1 | Exotic Liquid | Charlotte Cooper | 49 Gilbert St. | London | EC1 4SD | UK |
2 | New Orleans Cajun Delights | Shelley Burke | P.O. Box 78934 | New Orleans | 70117 | USA |
3 | Grandma Kelly's Homestead | Regina Murphy | 707 Oxford Rd. | Ann Arbor | 48104 | USA |
4 | Tokyo Traders | Yoshi Nagase | 9-8 Sekimai Musashino-shi | Tokyo | 100 | Japan |
SQL EXISTS Misollari
Quyidagi SQL bayonoti TRUE qaytaradi va narxi 20 dan kam bo'lgan mahsulotga ega yetkazib beruvchilarni ro'yxatga oladi:
Quyidagi SQL bayonoti TRUE qaytaradi va narxi 22 ga teng bo'lgan mahsulotga ega yetkazib beruvchilarni ro'yxatga oladi: