Is there an easier/more efficient way of doing the following WHERE conditions:
WHERE (Field LIKE %entry% OR Field2 LIKE %entry%)
AND (Field LIKE %entry2% OR Field2 LIKE %entry2%)
Please refer following link as well:
SELECT *
FROM mytable
WHERE MATCH(filed, field2) AGAINST ('entry' IN NATURAL LANGUAGE MODE)
AND (Field LIKE %entry2% OR Field2 LIKE %entry2%)
this part is a part of
(Field LIKE %entry% OR Field2 LIKE %entry%)
You can omit it.
You could do:
where concat_ws(' ', field1, field2) like '%entry%' and
concat_ws(' ', field1, field2) like '%entry2%'
The performance should be about the same.
If you want to improve performance, consider full text text.
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.