MySQL – Using a Column Name Inside the LIKE Keyword

When using the LIKE keyword in a MySQL query, I use it the most typical way, LIKE ‘%STRING%’. One day, I was in need to use a column name instead and could not figure out how to do it! At first, I tried to just replace the string value with the column name like this, LIKE (%t.column%). The end-result was not good as the LIKE keyword expects a string.

So, I thought of trying the CONCAT() function since that returns a string. And it worked!

Hope this helps someone!

Share: