By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,406 Members | 1,537 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,406 IT Pros & Developers. It's quick & easy.

MySQL WHERE MATCH problem

P: n/a
Hi,

I have the following table

CREATE TABLE `fulltext_sample` (
`copy` text,
FULLTEXT KEY `copy` (`copy`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO `fulltext_sample` VALUES ('This is a test to see how mysql
works');

Now I do a search for
SELECT * FROM fulltext_sample WHERE MATCH(copy) AGAINST('mysql');
and it return 0 results. Can someone please help me with this?

Thanks
Maz.
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Maziar,
I have the following table

CREATE TABLE `fulltext_sample` (
`copy` text,
FULLTEXT KEY `copy` (`copy`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


First you should always use an id field now...

If you look at the mysql manual for fulltext
(http://dev.mysql.com/doc/mysql/en/fulltext-search.html) the correct
way to create the table would be:
CREATE TABLE fulltext_sample (
id id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
copy TEXT,
FULLTEXT (copy)
);

What you pretty much did wrong at the top was trying to create a key. I
do not know exactly how mysql parses that but you may want to try over
with an ID column and the column for a copy.

Mike
Jul 17 '05 #2

P: n/a
Maziar,
What you pretty much did wrong at the top was trying to create a key. I
do not know exactly how mysql parses that but you may want to try over
with an ID column and the column for a copy.


Also one more quick note. From the manual:
" The search result is empty because the word ``MySQL'' is present in at
least 50% of the rows. As such, it is effectively treated as a stopword.
For large datasets, this is the most desirable behavior---a natural
language query should not return every second row from a 1GB table. For
small datasets, it may be less desirable."

Mike
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.