PGoCareerGoCareer prep tools
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

SQL · Theory

NOT

← All stacks

Theory

54/439

NOT

NOT flips a test. WHERE NOT (marks < 40) is marks >= 40, but NULL still fails the test (unknown). WHERE city NOT IN ('Pune') vs WHERE NOT city = 'Pune' — NULL city is not ‘Pune’ and not ‘not Pune’ in three-valued logic.

NOT LIKE, NOT EXISTS, != / <> are cousins. Prefer readable: WHERE marks >= 40 instead of NOT (marks < 40) when you can.

Trap — NOT IN with NULL. Trap: assuming NOT makes NULL into true.

On the example next to this theory: NOT: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

Exam tip

WHERE marks >= 40 rather than NOT (marks < 40).

NOT — sample query

-- NOT
CREATE TABLE demo (
  id INTEGER PRIMARY KEY,
  label TEXT NOT NULL,
  qty INTEGER DEFAULT 0
);
INSERT INTO demo (id, label, qty) VALUES
  (1, 'alpha', 2),
  (2, 'beta', 5);
SELECT label, qty FROM demo WHERE qty >= 2 ORDER BY qty DESC;

NOT: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

Short notes

  • DefNOT inverts a boolean test.
  • RulePrefer positive conditions when they read better.
  • TrapNOT IN + NULL. NOT does not turn NULL into true.

Questions

1

What does NOT do?

54 / 439

P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.