gpt4 book ai didi

Mysql where 多行

转载 作者:行者123 更新时间:2023-11-30 01:16:38 24 4
gpt4 key购买 nike

我有这个问题。

一张 table 。

id | routename | usersid   | 
1 | route 1 | 1,2,3,5 2 |
2 | route 2 | 5,20,15 3 |
4 | route 4 | 10,15,7,5 |

我需要,搜索 ej。 userid 5 在列 usersid...但我不知道该怎么做,因为有多行。

最佳答案

如果您无法更改架构,则必须使用 REGEXP 运算符来匹配正则表达式。例如

where column REGEXP '(^|,)5(,|$)'

这与字段开头或结尾处的数字 5 匹配,或者用逗号包围(或其任意组合),以避免匹配其他数字,例如 15551234567890

如果表很大,则执行速度会非常慢,因为它需要全表扫描

关于Mysql where 多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18995469/

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