10. MySQL Part 1: Install, Create, Insert and SELECT
10.7 LIKE, IN, BETWEEN and NULL
SELECT name FROM students WHERE name LIKE 'R%'; -- starts with R
SELECT name FROM students WHERE name LIKE '%Bagale'; -- ends with Bagale
SELECT name FROM students WHERE email LIKE '%a%@%'; -- 'a' before @
SELECT name FROM students WHERE name LIKE '_a%'; -- second letter a (_ = one char)
SELECT name, city FROM students WHERE city IN ('Pune', 'Nashik', 'Solapur');
SELECT name, city FROM students WHERE city NOT IN ('Pune');
SELECT name, age FROM students WHERE age BETWEEN 22 AND 25; -- inclusive
SELECT name, joined_on FROM students WHERE joined_on BETWEEN '2026-03-01' AND '2026-03-31';
SELECT name FROM students WHERE email IS NULL; -- not "= NULL"! → Raja
SELECT name FROM students WHERE age IS NOT NULL;
| Wildcard | Meaning | Example |
|---|---|---|
% |
Zero or more characters | 'Pu%' → Pune |
_ |
Exactly one character | 'R_ja' → Raja |
Ravindra Bagale's Tip
WHERE email = NULL lihun result rikama yeto aani khup students la vatte data nahi. NULL mhanje "mahit nahi" – tyachi = ne tulna hot nahi. Nehmi IS NULL / IS NOT NULL vapra. Interview madhe ha prashna yeto, lakshat theva.
Practice task
Find students whose name contains "a" as the second letter, students aged 21–24, students from Nagpur or Kolhapur using IN, and students with no email.