MySQL full text search result problem

full-text-searchMySQL

I have this query that does not return any results:

SELECT
    MATCH (e.firstname, e.lastname, e.tc_identity) AGAINST ('Baha') AS Score
    , e.*
FROM
    employees AS e
WHERE
    MATCH (e.firstname, e.lastname, e.tc_identity) AGAINST ('Baha' IN BOOLEAN MODE)
ORDER BY `Score` DESC;

firstname, lastname and tc_identity are of type varchar.

I have data in firstname like 'Bahadir', 'Bahadır', etc…

When I try to match against 'Baha', I get no results.

When I try to match against 'Bahadir' or 'Bahadır', I get no results.

What's the problem?

Best Answer

Your query is looking for the token = 'Baha'. You need a wildcard search for 'Baha*'.

Please try the following

SELECT
MATCH (`e`.`firstname`, `e`.`lastname`, `e`.`tc_identity`) AGAINST ('Baha*') AS `Score`,
`e`.*

FROM
`employees` AS `e`

WHERE
MATCH (`e`.`firstname`, `e`.`lastname`, `e`.`tc_identity`) AGAINST ('Baha*' IN BOOLEAN MODE)

ORDER BY `Score` DESC