搜索名称同时为 "test product" 和 "test-product" 的产品

Search products with name both "test product" and "test-product"

我的一个带有 CS-Cart 框架的购物车有搜索功能。在某些情况下,我有 "test products"、"test-products"、"test/products" 等产品。 我使用以下查询 "descr1.search_words LIKE %.$query.%" 来获取所有具有查询词的相应产品。 当我搜索 "test product" 时,它只显示 "test product"。 但我需要输出,因为它显示了上面提到的所有产品以及术语测试和产品。

提前致谢。

您可以尝试用通配符替换 space 进行比较:

where descr1.search_words like concat('%', replace($query, ' ', '%'), '%')

当然,这也会在关键字之间找到与其他词的匹配。