It is used with 2 wild-cards:
- _ means just a character
- % means any number of character (it also means empty word)
SELECT * FROM tableEmployees WHERE employeeName LIKE 'a%'
Select all employee records where employee name 1st character is 'a', 2nd character is any thing, 3rd character is 'b' and the rest is any character sequence.
SELECT * FROM tableEmployees WHERE employeeName LIKE 'a_b%'
If we need to find '_' or '%' in a string we must put escape character before them.
Example: Select all image records from images table where image name start with 'IMAGE_' and the rest is anything.
SELECT * FROM images WHERE employeePhoto LIKE 'IMAGEID\_%' ESCAPE '\'
No comments:
Post a Comment