如何根据两个逗号分隔值的列中的任何一个值获取记录 [英] How to fetch record on the basis of any one value from the column of two comma separated values
问题描述
你好,
可能是问题的标题没有正确定义我真正想问的问题。这是我的问题的更具体的描述
我的数据库中有一个下表用户,其中有一列,即包含多个值但以逗号分隔的类别
S.no.        姓名      类别
1           Ankit      前士兵,老年人
2             Ritu        寡妇,老年人
3          阿卡什            前战士
我想根据类别搜索记录
例如。如果我搜索
从 * >用户 其中类别= ' 高级公民'
然后它必须显示Ankit和Ritu记录。
如何做到这一点。
plz help
谢谢
试试,
select * from用户的类别如'%Senior Citizen%'
最简单的解决方案是
你可以使用LIKE子句
SELECT * FROM USER WHERE 类别 LIKE ' %Senior Citizen%'
< pre lang =SQL> 其中类别 LIKE ' %Senior Citizen%'
Hello,
May be the Question's title is not correctly defined what i actually wanted to ask. Here is the more specific description of my question
I have a following table 'User' in my database which has a column i.e. Category which contains multiple values but separated by commas
S.no. Name Category
1 Ankit Ex Soldier, Senior Citizen
2 Ritu Widow, Senior Citizen
3 Akash Ex soldier
I wanted to search the record on the basis of category
for eg. If i search
select * from User where Category='Senior Citizen'
Then it must show Ankit and Ritu record.
How to do this.
plz help
thanks
Try,
select * from User where Category like '%Senior Citizen%'
the easiest solution is
you can use LIKE clause
SELECT * FROM USER WHERE Category LIKE '%Senior Citizen%'
where category LIKE '%Senior Citizen%'
这篇关于如何根据两个逗号分隔值的列中的任何一个值获取记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!