的列表查询我有这个表Mysql的选择(搜索)与项目
recipe_tbl
id | name | ingredients
--------------------
1 | Banku | corn dough, cassava dough, okra, tomato, onion, pepper, garden eggs
2 | Jollof | rice, tomato, pepper, onion, spice
3 | fufui | cassava, okra, plantain
,我要选择具有匹配任何通过使用提供的名单的成分配方。
例如,如果用户搜索“coco,butter,okra”,他们应该得到ID为1和3的物品,因为它们都包含“OKRA”,并且如果他们搜索“辣椒,奶油,咖喱” ID为1和2,因为它们包含“PEPPER”。
我将GE高兴,如果有人能帮助我,谢谢
因为表不归你可能想使用MySQL的函数[FIND_IN_SET](https://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_find-in -set)将每个OR语句的结果一起添加,如果它> 0,则返回它。但不要求它很快..规范化的数据会执行得更快,因为它可以使用索引。你的另一种选择是考虑[全文搜索](https://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html#function_match)'匹配' – xQbert