Tuesday 14 August 2018

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!

0 comments:

Post a Comment