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

SQL · Theory

IN

← All stacks

Theory

51/439

IN

IN is OR for a list. WHERE city IN ('Pune','Goa','Delhi'); NOT IN is the opposite — beware NULL inside NOT IN (the whole test can become unknown).

IN (SELECT city FROM allowed) is a subquery form. For a joinable list, a table + JOIN is often clearer.

Trap — IN vs =. = is one value. Trap: NOT IN (1, NULL) surprises.

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

Exam tip

WHERE city IN ('Pune','Goa');

IN — sample query

-- IN
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;

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

Short notes

  • DefIN (a,b,c) = equal to any listed value.
  • RulePrefer IN over a long OR chain.
  • TrapNOT IN with NULL in the list.

Questions

1

Write IN for two cities.

51 / 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.