开发者

mysql fulltext search and special chars

I'm using php + mysql with a full text index. I have the following contents in the field I want to search:

"Hello: it's a test!"

"Hello i am also a test!"

When I search for "hello:", it finds both rows. But It should only find the first row - at least until I search for "hello%". The colon seems not tot b开发者_开发技巧e treated as a "normal" charakter.


This might be far to late but I can't reproduce your problem.

I have a table with your two entries:

Table: Test
ID Note
-- ---------
1  Hello: it's a test!
2  Hello i am also a test!

If I run your first search SELECT * FROM test t WHERE Note LIKE "Hello:" I get 0 rows in result, as expected because in this case LIKE looks for an exact match with the whole field.

If I run your second statement SELECT * FROM test t WHERE Note LIKE "Hello:%" I get one row back:

ID Note
-- ---------
1  Hello: it's a test!

Are you sure you have setup the table right for FULLTEXT indexing?

First of all your Table engine must be an MyISAM table. Then you need to create an index (Indices) for your column (in my case Note) of the FULLTEXT type.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜