SQLQuestion 01 of 14
WHERE and LIKE — find surnames containing A
Answer out loud or in your head first, then compare.
Answer
I filter individual rows in WHERE. % means any sequence of characters, and _ a single character.
SQL
-- employees(id, name)
SELECT id, name
FROM employees
WHERE name LIKE '%A%';In PostgreSQL: ILIKE '%a%' compares case-insensitively, according to the locale in use.
Pitfall: HAVING is for filtering groups. It isn't the right place for a plain surname filter. NULL doesn't match the pattern; if it should be included, you have to say so explicitly.
How did it go? Be honest — “Not yet” puts the question on your review list.