MySQL wildcard Like query with multiple words -
MySQL wildcard Like query with multiple words -
i have mysql query follows.
$query="select name,activity appid result > 5 , name :term order name asc limit 0,40"; $result = $pdo->prepare($query); $result->bindvalue(':term','%'.$_get["q"].'%',pdo::param_str); $result->execute();
what want this.
i have , entry want find
'news & weather'
however when type
'news weather'
it of course of study not find it. how can able type , retrieve entry?
regular expressions can trick:
select * appid name rlike 'news|weather' -- matches 'news' or 'weather'
another example:
select * appid name rlike 'news.*weather' -- matches 'news' , 'wether' -- characters in-between or none @ -- (ordered)
just 1 more:
select * appid name rlike '^news.{1,}weather$' -- matches text starts 'news' -- , has @ to the lowest degree 1 character before -- ending 'weather'
regular espressions can used create complicated filters on text fields. read link above more information.
if can add together full-text index table, full-text search might improve way go this. specifically, boolean full-text search:
select * appid match(name) against (+news +weather)
mysql
Comments
Post a Comment