我在IN
语句中使用子查询,但结果为空。我猜这个问题是数据类型的,但我无法解决这个问题。SQL子查询返回NULL IN语句
这是工作:
select *
from qcpcs a with(NOLOCK)
where status = 0
and active = 1
and Convert(varchar(8),assigned_to_dept_id) in (10000076, 10000049)
这不是工作
select *
from qcpcs a with(NOLOCK)
where status = 0
and active = 1
and Convert(varchar(8),assigned_to_dept_id) in (select department_ids from users b
where b.[id] = 10000021)
这是子查询的结果是:
请添加文字,而不是图片。 – jarlh
请将查询发布为文本而不是图片 – TheGameiswar
当您自己运行子查询时,您的子查询是否返回正确的ID? – iamdave