开发者

MySQL - search in longtext

开发者 https://www.devze.com 2023-03-13 13:55 出处:网络
I believe this question will be useful for many MySQL newbies like me. Are there any means to search through the LONGTEXT type? As I see, FULLTEXT can be used only for TEXT fields, which doesn\'t suit

I believe this question will be useful for many MySQL newbies like me. Are there any means to search through the LONGTEXT type? As I see, FULLTEXT can be used only for TEXT fields, which doesn't suit me, because of size.

P.S. I heard around, that LONGTEXT is stored as a BLOB, and therefore can't be 开发者_如何转开发searched with standard methods. But are there any workarounds?

Thanks for your time.


You are correct, FULLTEXT doesn't work with LONGTEXT column types, according to the documentation.

You can implement your own searching through the LIKE functionality:

select postid,content from POSTS where content like '%keyword%';

but this will be nowhere as efficient as using FULLTEXT searching.


I think you should consider using a concatenation of data stored in a FullText, and an ID stored in another field.

If you require the data to be seperated into fields you can use another table with seperated fields joined with the first table by ID. This way you can use both LongText (in the table with seperate fields), and fulltext in the search table.

0

精彩评论

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