gpt4 book ai didi

mysql - 使用逗号分隔值选择 mysql 列

转载 作者:可可西里 更新时间:2023-11-01 07:15:00 26 4
gpt4 key购买 nike

假设我有一张这样的 table 。

+-------------+---------------+----------------+---------------++     id      +    column 1   +    column 2    +    column 3   ++-------------+---------------+----------------+---------------+ +      1      +     values    +     values     + a, b, c, d, e +  +-------------+---------------+----------------+---------------+

My query can be like this

SELECT * FROM table WHERE column 1 = 'values' AND column 3 = '$variable'

$变量可以是从 a 到 e 的任何值

有没有办法使用查询来选择我想要的行?

最佳答案

使用 FIND_IN_SET() -- mysql 搜索字符串的内置函数

SELECT  *
FROM tableName
WHERE column 1 = 'values' and FIND_IN_SET('a',column 3 )>0

关于mysql - 使用逗号分隔值选择 mysql 列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17648736/

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