Searching from a mysql database based on a string in php -
i have string foo = "a,b". want search in mysql database user_id while comparing string likes field. likes field has data in format interest => c v d b. different characters seperated space. tried using result not upto mark. how can go it?
this code
select user_id users interest %foo%;
mysql not support multiple keyword search in set field, should add or
condition of each search keyword regexp
if format interest like=> a,c,v,d,b
can use find_in_set()
function otherwise regexp
provide exact search.
select user_id users interest regexp '[[:<:]]a[[:>:]]' , interest regexp '[[:<:]]b[[:>:]]'
this query search a
, b
in field not aa
, bbax
like
not support exact search.
Comments
Post a Comment