gpt4 book ai didi

php - MySql : can i query "WHERE ' $str' LIKE %table. col%"?

转载 作者:太空宇宙 更新时间:2023-11-03 10:28:07 28 4
gpt4 key购买 nike

基本上我想在搜索时将通配符添加到 col 值...

通常我是这样反过来做的:

WHERE cakes.cake_name LIKE '%$cake_search%'

但是现在我希望它与逆匹配:

the user searches for 'treacle
sponge
', i want this to match a row where the cake_name column = 'sponge'.

这可能吗?

最佳答案

WHERE '$cake_search' LIKE  concat('%',cakes.cake_name, '%')

应该可以。它将需要全表扫描,但反向查询也需要。你调查过full text search吗?对于 MySQL?它可能会使这种查询更有效率。

关于php - MySql : can i query "WHERE ' $str' LIKE %table. col%"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3255298/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com