简体   繁体   English

如何从合并数据的列中获取结果?

[英]How to get result from a column with combined data?

data: 数据:

id  bb
1  14,35
2  5,11,12,125,36
3  3,23,45,15,1
4  651
5  5,1,6
6  1,7

For example, i wan't get id which with value '1'. 例如,我将无法获得ID,其值为'1'。 So id(3,5,6) should return , but not others with '14' or '11'. 因此id(3,5,6)应该返回,但其他不返回'14'或'11'的返回值。

DB: Mysql DB:MySQL

This is not the most efficient solution but it might give you what you want off the table: 这不是最有效的解决方案,但可能会给您带来您想要的东西:

select id from MyTable where bb like '%,1,%' union 

select id from MyTable where bb like '1,%' union 

select id from MyTable where bb like '%,1' union 

select id from MyTable where bb like '1'

cheers 干杯

select * from test where find_in_set('1',bbb)

要么

select * from test where bbb REGEXP '(^|,)1(,|$)'

Am I missing something? 我想念什么吗?

SELECT *
FROM   MyTable
WHERE  (id = 3) or (id = 5) or (id = 6)

您可以从mytable中选择* *,例如ID为“ 14%”或“ 11%”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM