How to use LIKE for case insensitive search of partial terms

Viewed 87

I have a table with id, date, time, user, channel, message and I'm trying to get records based on a username using:

SELECT * FROM log WHERE user LIKE '%dog%'

I have at least one user called Dogge#2252, and the query does not return anything. Am I using LIKE wrong or how do I fix this issue?

To complicate thing further, using

SELECT * FROM log WHERE user LIKE '%admin%'

does return the Dogge#2252 user.

1 Answers

Thanks to @OldProgrammer: changing

SELECT * FROM log WHERE user LIKE '%dog%'

to

SELECT * FROM log WHERE user ILIKE '%dog%'

worked.

Related