我正在做一個圖書館系統的整理和修復雜亂的書名。 我想編寫一個SQL查詢或PHP代碼,用於搜索與一個句子中的MySQL表中的數據匹配的關鍵字。搜索與MySQL中的數據匹配的關鍵字
[tbl_keywords]
id | keyword | title
====================================================================
1 | Harry Potter | Harry Potter
2 | Philosopher's Stone | [Harry Potter] Harry Potter and the Philosopher's Stone
3 | Chamber of Secrets | [Harry Potter] Harry Potter and the Chamber of Secrets
4 | Dr. Seuss | Dr. Seuss
5 | Green Eggs and Ham | [Dr. Seuss] Green Eggs and Ham
6 | The Cat in the Hat | [Dr. Seuss] The Cat in the Hat
例如,
"Harry Potter(1)" => matches 1
"[Harry Potter] Harry Potter and the Philosopher's Stone(1)" => matches 1 and 2
"(HARRY POTTER2) THE CHAMBER OF SECRETS" => matches 1 and 3
"Dr. Seuss - Green Back Book" => matches 4
"Green eggs and ham" => matches 5
"the cat in the hat(Dr. Seuss)" => matches 4 and 6
而且這是可能的(易於實現)?如果它是太多的事情要做,我只需添加變量值到表..
"HarryPotter" => matches 1
"Dr.Seuss" => matches 4
"Dr Seuss" => matches 4
如何做到這一點,將不勝感激任何幫助或想法。提前致謝。
看看這個[* FullText Search(1)*](http://dev.mysql.com/doc/refman/5.0/en/fulltext -search.html)[示例(2)](http://devzone.zend.com/26/using-mysql-full-text-searching/) –