gpt4 book ai didi

Mysql查询包含

转载 作者:行者123 更新时间:2023-11-29 12:40:41 25 4
gpt4 key购买 nike

id  name(varhcar)
2 15
3 15,23
4 1315,424
5 1512,2323
6 23,15,345
7 253,234,15

我需要找出那些包含 15 的值,这意味着我需要 2,3,6,7 而不是 4,5。以上是样本数据,实时数据可以是任意数字。有人可以帮我吗?

最佳答案

如果您的数据库较小,请考虑使用 find_in_set 函数:

select * from your_table 
where find_in_set('15',name);

如果您有一个大表,请考虑将模型更改为主从表以提高速度。

关于Mysql查询包含,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26163765/

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