如何获取表中哪一列包含某个值的行? [英] How to get row of table in which column contains some value.?
问题描述
我有 TBL_STD_FIELD_VALUE 表,在该 FLD_USER_IDS 列中.它的数据类型是 varchar(255).我在该列中存储以,"分隔的电子邮件 ID.
I have TBL_STD_FIELD_VALUE table, in that FLD_USER_IDS column is present. It's datatype is varchar(255). I am storing email ids separated by ',' in that column.
以下是 FLD_USER_IDS 列值.
Below is FLD_USER_IDS column values.
我想检索行,其中 FLD_USER_IDS 列包含 'akshay_goel2013@isb.gappspilot.info' 条目.
I want to retrieve rows, in which FLD_USER_IDS column contains 'akshay_goel2013@isb.gappspilot.info' entry.
下面是我的sql查询
select fieldValues.FLD_USER_IDS from TBL_STD_FIELD_VALUE as fieldValues where 'akshay_goel2013@isb.gappspilot.info' IN (fieldValues.FLD_USER_IDS)
但它没有给出任何结果.有什么问题吗.?
But it is not giving any result. is something wrong in it.?
推荐答案
您必须使用 FIND_IN_SET
以获取更多信息,请参阅 文档
You have to use FIND_IN_SET
for more information see the documentation
这个查询应该给你正确的结果:
This query should give you the correct result:
select fieldValues.FLD_USER_IDS from TBL_STD_FIELD_VALUE as fieldValues where FIND_IN_SET ('akshay_goel2013@isb.gappspilot.info',fieldValues.FLD_USER_IDS)
这篇关于如何获取表中哪一列包含某个值的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!