从整数类型字符串中获取值! [英] Get value from integer type string!
本文介绍了从整数类型字符串中获取值!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一个表tblTest,我保存类别ID,如(1,2,3,4)。 category id是整数,但用户可以选择多个类别。所以我想从这个字符串中获取类别名称(类别A,类别B,类别C,..)。有什么想法吗?
解决方案
你可以在sql中使用'in'子句选择多个id多个项目
SELECT * FROM tableName 其中 id (value1,value2,value3)
< blockquote>
SELECT CategoryId,CategoryName
FROM 类别
WHERE CategryId IN ( 1 , 2 , 3 )
或
SELECT CategoryId,CategoryName
FROM 类别
WHERE CategryName IN (' A类,' B类,' C类)
Hello all,
I have a table tblTest where I am saving category id like (1,2,3,4). category id is integer but user can select more than one category. So i want to get category name from this string like (category A,category B, category C,..) . Have any idea for same?
解决方案
you can select mutiple item by multiple id using 'in' clause in sql like this
SELECT * FROM tableName where id in (value1,value2,value3)
SELECT CategoryId, CategoryName FROM Categories WHERE CategryId IN (1,2,3)
or
SELECT CategoryId, CategoryName FROM Categories WHERE CategryName IN ('Category A','Category B','Category C')
这篇关于从整数类型字符串中获取值!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文