我正在整理图书馆系统并修复凌乱的书名。我想编写一个 SQL 查询或 PHP 代码来搜索与 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
任何有关如何执行此操作的帮助或想法将不胜感激。提前致谢。