mysql 下locate和find_in_set的使用

LOCATE(substr,str)
select * from table where locate(UID,SALE_ID)>0 order by CREATE_TIME desc  limit 10

取出UID存在于SALE_ID内的数据,但有缺陷:str=123,456,789并且substr=12情况下,localte(substr,str)>0值为true。

此情况下推荐使用find_in_set(substr,str),用法类似。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
FIND_IN_SET函数是MySQL中的一个内置模糊搜索函数,用于在一个字符串列表中查找某个值。根据引用中的描述,如果第一个参数是一个常数字符串,而第二个参数是type SET列,则FIND_IN_SET函数会进行优化,使用比特计算。这种优化可以提高函数的性能。 相比于使用LIKE配合通配符进行模糊搜索查询,FIND_IN_SET函数在性能上要更快一些,除了最后一个之外的其他三个函数在性能方面都比使用LIKE更快。 因此,如果你需要在MySQL中进行模糊搜索并且性能是一个重要的考虑因素,可以考虑使用FIND_IN_SET函数。它可以提供更高效的查询结果。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [MySQL高效模糊搜索之内置函数locate instr position find_in_set使用详解](https://download.csdn.net/download/weixin_38663415/12824892)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [mysqlfind_in_set()和in()用法比较](https://blog.csdn.net/weixin_29064009/article/details/113384720)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值