How to use Column Name Inside The LIKE Statement
Tags: development, mysql, sql
LIKE keyword is usually used to search for a string value ( LIKE (‘%STRING%’) ).
If you need to search one field based on the value from another one, the replacing the string value with the column name like this LIKE (%table.column_name%) or some syntax like LIKE (’%'+`table.column_name`+’%') won’t work.
You need to use the CONCAT operator to make it the correct SQL statement.
LIKE CONCAT(‘%’, table.column_name, ‘%’)
Posted: July 1st, 2010 under Software.
Comments: none
- No Related Posts


Write a comment