Reputation: 686
Here is what I was want to Optimize this query
SELECT *
FROM users
where `username` like "%abc%"
or `name` like "%abc%"
or `email` like "%abc%"
This search get result from users where any of username
, name
, email
like %abc%
So I tried to use in with like But
I was looking for mysql Like in and I have found this answer stackoverflow :Mysql like in
So the solution was regex
But I want to make the regex not use OR
I want to be like this
SELECT * from users where abc REGEXP 'username|name|email';
So the answer
Upvotes: 2
Views: 65
Reputation: 43683
Do you mean something like this? >>
SELECT * from users where CONCAT(username, ',', name, ',', email) REGEXP 'abc'
Upvotes: 1