NOT operator

NOT operatori boshqa operatorlar bilan birgalikda ishlatiladi va natijani qarama-qarshi (salbiy) qilish uchun ishlatiladi.

SU

NOT Operatori

NOT operatori boshqa operatorlar bilan birgalikda ishlatiladi va natijani qarama-qarshi (salbiy) qilish uchun ishlatiladi.

Quyidagi tanlov bayonotida biz Ispaniyadan bo‘lmagan barcha mijozlarni qaytarishni istaymiz:

Misol O'zingizning SQL serveringizni oling Ispaniyadan bo‘lmagan mijozlarni tanlang:

SELECT * FROM Customers
WHERE NOT Country = 'Spain';

Yuqoridagi misolda NOT operatori = operatori bilan birgalikda ishlatilgan, ammo uni boshqa taqqoslash va/yoki mantiqiy operatorlar bilan birgalikda ham ishlatish mumkin. Quyidagi misollarga qarang.

Sintaksis

SELECT column1, column2, ...
FROM table_name
WHERE NOT condition;

Demo Ma'lumotlar Bazasi

Quyida misollarda ishlatiladigan Customers jadvalidan tanlov keltirilgan:

CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
1Alfreds FutterkisteMaria AndersObere Str. 57Berlin12209Germany
2Ana Trujillo Emparedados y heladosAna TrujilloAvda. de la Constitución 2222México D.F.05021Mexico
3Antonio Moreno TaqueríaAntonio MorenoMataderos 2312México D.F.05023Mexico
4Around the HornThomas Hardy120 Hanover Sq.LondonWA1 1DPUK
5Berglunds snabbköpChristina BerglundBerguvsvägen 8LuleåS-958 22Sweden

NOT LIKE

Misol Ismi "A" harfi bilan boshlanmaydigan mijozlarni tanlang:

SELECT * FROM Customers
WHERE CustomerName NOT LIKE 'A%';

NOT BETWEEN

Misol Mijozlar orasida CustomerID 10 va 60 oralig'ida bo'lmaganlarni tanlang:

SELECT * FROM Customers
WHERE CustomerID NOT BETWEEN 10 AND 60;

NOT IN

Misol Parij yoki Londondan bo‘lmagan mijozlarni tanlang:

SELECT * FROM Customers
WHERE City NOT IN ('Paris', 'London');

NOT Greater Than

Misol CustomerID 50 dan katta bo'lmagan mijozlarni tanlang:

SELECT * FROM Customers
WHERE NOT CustomerID > 50;

Eslatma: 50 dan katta bo'lmagan operator: !> ham shu natijani beradi.

NOT Less Than

Misol CustomerID 50 dan kichik bo'lmagan mijozlarni tanlang:

SELECT * FROM Customers
WHERE NOT CustomerId < 50;

Eslatma

50 dan kichik bo'lmagan operator: !< ham shu natijani beradi.

Ushbu sahifada

Xato haqida xabar berish