LIKE
%
- represents any number of characters
_
- represents one single character Select all students which lastname contains 'უა' with
LIKE
operator
SELECT *
FROM students
WHERE last_name LIKE '%უა%'
Select all students which
lastname
ends with 'უა' using
LIKE
operator
SELECT *
FROM students
WHERE last_name LIKE '%უა'
Select all students which
lastname
does not contain 'უა' with
NOT LIKE
operator
SELECT *
FROM students
WHERE last_name NOT LIKE '%უა%'
Select all students where
lastname
starts with any two character followed with
უა
and we don't care what the other following symbols are (with
_
)
SELECT *
FROM students
WHERE last_name LIKE '__უა%'
Select all students where
lastname
is exactly 5 characters long and the second symbol is
SELECT *
FROM students
WHERE last_name LIKE '_უ___'
Select all students where
lastname
is exactly 5 characters, starts with
a
and ends with
y
and has exacly any three letters between them
SELECT *
FROM students
WHERE last_name LIKE 'a___y'
Select all students where
lastname
ends with either
ძე
or
შვილი
SELECT *
FROM students
WHERE last_name LIKE '%ძე' OR last_name LIKE '%შვილი'
by Valeri Tandilashvili
4 years ago
MySQL
LIKE
1
Pro tip: use ```triple backticks around text``` to write in code fences