Can we apply the LIKE operator to values other than TEXT?


#1

Question

Can we apply the LIKE operator to values other than TEXT?

Answer

Yes, you can apply the LIKE operator to numerical values as well.

Whenever you use LIKE however, you must always wrap the pattern within a pair of quotations, whether for matching a number or a string.

Example

/* 
This will select movies where the id number
starts with 2 and is followed by any two numbers.
*/
SELECT * 
FROM movies
WHERE id LIKE '2__';