简体   繁体   中英

MySQL REGEXP Search

I have made a search engine which works well, but I want it to disregard symbols in the database entries.

eg I search for A*BC

In the database I have a column that contains ABC.

I would like it to bring back this record even thought it has symbols in.

How would I do this?


Hi, I tried that but it does not work.

Here is my code:

$query = '%' . rawurlencode($queryRaw) . '%' ;

        $queryClean = ereg_replace("[^A-Za-z0-9]", "%", $query) ;

        $result = $dbh->prepare("SELECT supplier_details.id as supid, name, languages.languages, countries.country
                                 FROM supplier_details, languages, countries
                                 WHERE languageRef = languages.id
                                 AND countryRef = countries.id
                                 AND (name LIKE ? OR name LIKE ?)
                                 LIMIT 50") ;
            $result->bindParam(1, $query, PDO::PARAM_INT) ;
            $result->bindParam(2, $queryClean, PDO::PARAM_INT) ;
        $result->execute() ;
select * 
from tbl
where clmn like '%A%B%C%'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM