将一组数字连接成一个字符串 [英] concatenate group of numbers into a string
本文介绍了将一组数字连接成一个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi frens
我有一个查询,它返回一组ID ex:str abc = select employee from employee where gt> ; 1000
我必须将这些值(即abc)传递给另一个查询(例如:select * from [Table]其中id IN(1.2,3,4)....
如何将这些id作为逗号分隔ID获取
请给我建议
谢谢
darshan
Hi frens
I ve a query which returns a set of IDs ex: str abc= select id from employee where salary>1000
I have to pass these values(ie, abc) into the other query ( ex: select * from [Table] where id IN (1.2,3,4 ) ....
How to get those ids as a comma separated ids
Please suggest me guys
thanks
darshan
推荐答案
我找到了类似问题的答案: sql-如何连接 - 结果 [ ^ ]
I found this answer to a similar question: sql-how-to-concatenate-results[^]
declare @result varchar(500)
set @result = ''
select @result = @result + ModuleValue + ', '
from TableX where ModuleId = @ModuleId
根据我的情况尝试下面的Sql字符串:
从[Table]中选择*,其中id IN(1.2,3,4)和salary> 1000
According to me kindly try below Sql string:
Select * from [Table] where id IN (1.2,3,4 ) and salary>1000
easy ...不需要做更多的代码...
只需将您的查询直接写为in子句中的子查询:)
easy... do not need to do more code...
just write directly your query as subquery inside "in" clause :)
select * from [Table]
where id IN (select id from employee where salary>1000)
快乐编码!
:)
Happy Coding!
:)
这篇关于将一组数字连接成一个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文