full text search doesn't find anything

**EDIT**

ok so i found the problam, it was that the min word length for the search was 4, i changed it to 3 but now it only finds the row 1 data and not row 2 data aswell...

-----original question:----

I have a MyISAM table on my phpmyadmin like this:

table name: `users`
coulmn name: `name`
row 1 data: 'dan'
row 2 data: 'dan252'

(it's just the important part of it)

now the name is fulltext index field, im using this query:

SELECT * FROM `users` WHERE MATCH(`name`) AGAINST('dan')

but phpmyadmin returns:

MySQL returned an empty result set (i.e. zero rows). ( Query took 0.0004 sec )

why it's not finding anything?

*EDIT*

ok so i found the problam, it was that the min word length for the search was 4, i changed it to 3 but now it only finds the row 1 data and not row 2 data aswell...

Answers


MATCH only works on columns with FULLTEXT indicing. And FULLTEXT indicing only works on MyISAM tables.

Secondly, 'dan' is probably too short to use on a MATCH.

Thirdly, if your search term matches more than 50% of your rows, the term is considered too common and the search fails.

Have a read here.


Try this.

SELECT * FROM users WHERE MATCH (name) AGAINST ('dan');

I guess you are using apostrophes for tablename and in MATCH. This is wrong. Try it and let me know if this works.


I guess you are trying to return all with 'dan' in them You could try the LIKE command.

SELECT * FROM users WHERE name LIKE '%dan%'

That will return 'dan' and 'dan252' and (if he was in the table) '123dan456'.

You could also try

SELECT * FROM users Match(name) AGAINST('+dan*')

That should return the same thing and is probably more efficient. If you are only trying to use 'dan' then use as @Kirishna says.

SELECT * FROM users WHERE MATCH (name) AGAINST ('dan')

Need Your Help

Would you use the S#arp Architecture in a new commercial project?

.net architecture frameworks s#arp-architecture

The S#arp Architecture seems really cool, but do you think it's still too new to make the commitment to it in an important new project? (Let's assume the project appears to be a good fit for it at ...

Multiple Expression in Angular Click

javascript angularjs

I'm putting two expressions in an Angular ngClick directive. Why would $scope.refresh not = Date.now()? Does it only do certain kinds of expressions?