I have a table like this
name | surname | email | tel
Edwin | Williams | edwin@aa.com | 123456
Luke | Evan | luke@bb.com | 987456
I need to search "Edwin Williams" or "Williams Edwin" as the same.
I tried
CONCAT_WS (' ', name, surname, email, email2) LIKE '%".addslashes($_POST['search'])."%'
OR
CONCAT_WS (' ', surname, name, email, email2) LIKE '%".addslashes($_POST['search'])."%'
but I don't like it, in I search "123456 Edwin" I don't find anything.
I have table in InnoDb, I prefer not use MyISAM fulltext.
I think you want:
WHERE CONCAT_WS(' ', name, surname, email, email2, tel) REGEXP REPLACE(CONCAT('%', $_POST['search'], '%'), ' ', '|')
You want a vertical bar to get "OR" for a regular expression.
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.