有没有办法可以将这个全文搜索查询从 MySQL 翻译成 SQL Server?
SELECT *, MATCH(title) AGAINST('My Title' IN BOOLEAN MODE) AS score FROM books
WHERE MATCH(title) AGAINST('My Title' IN BOOLEAN MODE) ORDER BY score DESC,
books.title ASC
如果有帮助,我专门使用 SQL Server 2000。我没有使用更新版本的选项。:S
这是一个示例场景。
创建表:
--
-- Table structure for table `books`
--
CREATE TABLE IF NOT EXISTS `books` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `title` (`title`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
--
-- Index the title column
--
ALTER TABLE `books` ADD INDEX ( `title` )
--
-- Dumping data for table `books`
--
INSERT INTO `books` (`id`, `title`) VALUES
(1, 'My Title'),
(2, 'My Title'),
(3, 'Not My Title'),
(4, 'Other Title'),
(5, 'Not Related'),
(6, 'Not Related Either');
执行查询:
SELECT *, MATCH(title) AGAINST('My Title' IN BOOLEAN MODE) AS score FROM books
WHERE MATCH(title) AGAINST('My Title' IN BOOLEAN MODE) ORDER BY score DESC,
books.title ASC
这是返回的内容:
id title score
1 My Title 1
2 My Title 1
3 Not My Title 1
4 Other Title 1
感谢您的时间。