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
Writing WHERE email = NULL gives an empty result, and many students think there's no data. NULL means "unknown" – it can't be compared with =. Always use IS NULL / IS NOT NULL. This question comes up in interviews – remember it.
Ravindra Bagale's Tip – मराठी
WHERE email = NULL लिहून result रिकामा येतो आणि बऱ्याच students ना वाटतं data नाही. NULL म्हणजे "माहीत नाही" – त्याची = ने तुलना होत नाही. नेहमी IS NULL / IS NOT NULL वापरा. Interview मध्ये हा प्रश्न येतो, लक्षात ठेवा.
Ravindra Bagale's Tip – हिंदी
WHERE email = NULL लिखने से result ख़ाली आता है और बहुत से students को लगता है data नहीं है. NULL यानी "पता नहीं" – उसकी = से तुलना नहीं होती. हमेशा IS NULL / IS NOT NULL इस्तेमाल करो. Interview में यह सवाल आता है, याद रखो.
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.