0

I have a table with products

| Id | product           |
| -- | ----------------- |
| 1  | red t-shirt       |
| 2  | white sweat-shirt |
| 3  | nice tee-shirts   |
| 4  | tactac badadoum   |

I'm using this query:

`SELECT Id, product FROM mytable WHERE MATCH(product) AGAINST ('tee-shirt*' IN BOOLEAN MODE)`

It returns the 3 first rows but I was expecting it returns only rows 1 and 3.

I would like it returns only results starting with 't-shirt', 'tee-shirt', ... but not results with characters preceding these words. Is it possible ?

(I'm using MySQL 5.7)

vegmaster
  • 37
  • 6
  • 1
    Perhaps you meant "does not seem to work"? – Stu Apr 13 '23 at 08:20
  • sorry for the mistake :) – vegmaster Apr 13 '23 at 09:07
  • 2
    For the fulltext search, hyphenated words are 2 separate words, see [How to allow fulltext searching with hyphens in the search query](https://stackoverflow.com/q/5192499) (or [here](https://stackoverflow.com/q/21296870), and it works similarly for [innodb](https://stackoverflow.com/a/46756090)). Your search currently finds "tee" and/or "shirt". Also note that you don't find the "t" in "t-shirt" (just the 2nd word "shirt", which is why you also find "sweat-shirt"). – Solarflare Apr 13 '23 at 12:00
  • @Solarflare thank you for your comment. It helped me to understand what was happening. – vegmaster Apr 14 '23 at 14:27

0 Answers0