AND — SQL Technical Interview Questions & Answers

AND

AND

  • AND means both conditions true. WHERE marks >= 40 AND city = 'Pune'; Pune students who passed. If one side is false, the row is out.
  • Chain: a AND b AND c. Mix with OR only with brackets.
  • Trap: WHERE marks > 40 AND marks < 40 — empty on purpose. Trap: AND vs comma in English ‘students in Pune and Goa’ — that is OR for city, not AND.
  • On the example next to this theory: AND — wHERE combines predicates with AND/OR; LIKE does pattern match.

Technical Interview Tip: WHERE marks >= 40 AND city = 'Pune';

Code Examples for AND

AND — 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 — wHERE combines predicates with AND/OR; LIKE does pattern match.

How to Explain AND to an Interviewer

What does AND do?

Both sides true Example: passed AND from Pune