我的Sql IN查询在哪里Clause给出一行作为输出

时间:2013-05-09 12:00:30

标签: mysql

此查询仅返回单行

Set @id='2,3,4,5,6,7,8,9';
Set @typers=1;
Select * from Employee where (@typers=1 and pkEmpId in (@id));

如果我们在IN Query中直接分配2,3,4,5,6,7,8,9,我知道这是因为" ' "

但是当我在过程

中传递值作为参数时,我遇到了同样的问题
call CalculateStandardFinalRun('0','4','1900-01-01 00:00:00','1900-01-01 00:00:00','5','1','2,3,4,5,6,7,8,9');

我如何获得所有价值

2 个答案:

答案 0 :(得分:1)

我认为你应该尝试这个

Select * from Employee where (@typers=1 and FIND_IN_SET(pkEmpId, @id)));

答案 1 :(得分:0)

您的@id项是一个字符串。您可能已经很好地使用了这种语法

  pkEmpId in ('something-or-other')

它不会做你想要的。 in列表中的每个项目都必须是单独的数据项。