MySQL 列中的多个值 [英] Multiple values in column in MySQL
本文介绍了MySQL 列中的多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个包含具有多个值的字段的表.我熟悉set"类型,但问题是我不完全知道高级中的所有值.
I want to create a table which contains a field with multiple values. I familiar with the "set" type, but the problem is that I don't know exactly all the value in advanced.
有人知道解决办法吗?
谢谢
推荐答案
您可以将它们作为逗号分隔值(字符串)放在列中,并使用find_in_set
查询功能(以防万一).
You can put them as comma-separated values (strings) in the column, and use the find_in_set
function to query (in case you want to).
添加:
您可以稍后查询,如下所示:
You could later query as shown below:
例如,要搜索在该列中将 value1
作为值的所有行,请使用:
For instance, to search for all rows which have value1
as a value in that column, use this:
SELECT T1.column
FROM Table T1
WHERE find_in_set('value1', T1.column) > 0;
这篇关于MySQL 列中的多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文