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

SQL · Theory

AND OR

← All stacks

Theory

48/439

AND OR

Mix AND and OR only with parentheses. WHERE (city = 'Pune' OR city = 'Goa') AND marks < 40; fail students from those cities.

Without brackets MySQL does AND first. Your English sentence is not the operator order.

Trap — writing AND/OR chains from spoken language without drawing two groups on paper.

On the example next to this theory — AND OR — wHERE combines predicates with AND/OR; LIKE does pattern match.

Exam tip

(city = 'Pune' OR city = 'Goa') AND marks < 40

AND OR — sample query

CREATE TABLE products (id INTEGER PRIMARY KEY, name TEXT, price REAL);
INSERT INTO products VALUES (1, 'Pen', 10), (2, 'Book', 200), (3, 'Bag', 50);
SELECT * FROM products
WHERE price BETWEEN 20 AND 150 AND name LIKE 'B%';

AND OR — wHERE combines predicates with AND/OR; LIKE does pattern match.

Short notes

  • DefBracket OR groups, then AND the rest.
  • Rule(A OR B) AND C.
  • TrapRelying on default precedence.

Questions

1

How do you mix AND and OR?

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