Categories

RSS

 Subscribe


Ads


$10 Off $150 Coupon! Click Here!

$5 Off $50 Coupon! Click Here!

Site search

Archive

How to use Column Name Inside The LIKE Statement

Tags: , ,

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, ‘%’)
  


Related Posts:
  • No Related Posts

Write a comment