-1

我有桌子

CREATE TABLE `articles` 
(
  `id` int(11) NOT NULL default '0',
  `title` varchar(65) default NULL,
  `topic` varchar(25) NOT NULL default '',
  `author` varchar(25) NOT NULL default '',
  `ondate` datetime NOT NULL default '0000-00-00 00:00:00',
  `body` text NOT NULL,
);

我使用以下查询在其上添加索引:

ALTER TABLE articles ADD FULLTEXT(title,body);

当我选择如下查询时,如果标题包含“cvs”、“cvsssh”、“cvsrepository”之类的词,我想要结果

SELECT id,title FROM articles WHERE MATCH (title) AGAINST('cvs');

但它只返回与 cvs 相关的一行。它正在做单词匹配我想要字符匹配

请帮助我...在此先感谢。

问候印度

4

2 回答 2

1

您是否尝试过使用 like 运算符?

例如:

SELECT id,title 
FROM articles 
WHERE title like '%cvs%';

http://dev.mysql.com/doc/refman/5.0/en/pattern-matching.html

于 2012-09-10T08:00:14.730 回答
0

应该是这样的:-

SELECT id,title FROM articles WHERE title like 'cvs%';

这将为您提供从 csv.. 字符开始的输出。

如果你使用'%cvs%' 那么它会给你包含 cvs 的输出

于 2012-09-10T08:15:11.563 回答