Trouble with MATCH ... AGAINST in MYSQL

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
htdung
Forum Newbie
Posts: 17
Joined: Sun Apr 27, 2008 6:35 am

Trouble with MATCH ... AGAINST in MYSQL

Post by htdung »

I have a table like this:

Code: Select all

CREATE TABLE `lt_producer` (
  `producerID` int(11) unsigned NOT NULL default '0',
  `producerName` varchar(50) default NULL,
  `producerLogo` varchar(100) default NULL,
  `module` text,
  `timeupdate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  PRIMARY KEY  (`producerID`),
  KEY `producerID` (`producerID`),
  FULLTEXT KEY `FULLTEXT` (`module`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
I have input some records and run a query like following:

Code: Select all

select producerName,module from lt_producer where match(module) against ('abc*');
The result has no record even the table has two record with the words 'abc' in `module` field.
Who got that? Help me !
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Trouble with MATCH ... AGAINST in MYSQL

Post by pickle »

You're not looking for 'abc', you're looking for 'abc*'. Take out the asterix.

Also, put the match...against clause in the field list as well as the where clause - that'll sort your results by relevancy.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply