开发者

What is the best way of searching mysql table field for the ending of a fiels?

开发者 https://www.devze.com 2023-01-11 09:12 出处:网络
I have been开发者_开发百科 told that searching in a MySQL database with LIKE \'%wordend\' is bad because it takes very long time.

I have been开发者_开发百科 told that searching in a MySQL database with LIKE '%wordend' is bad because it takes very long time.

What is the best way of searching on the end of a field?

Should I make an extra field where field that needs to be searched backwards is stored backwards, seems like an ok idea to me since it will give the benefit of indexing!


Should I make an extra field where field that needs to be searched backwards is stored backwards

Yep, store the text field in reverse. Then you can search for it LIKE 'dnedrow%' ('wordend' spelled backwards).

You are correct in that indexes on character fields start from the left.

0

精彩评论

暂无评论...
验证码 换一张
取 消