yy455363056
2016-05-04 07:03 阅读 1.3k

db2递归结果集作为查询条件时报错

递归在db2中没有问题,但要是把递归的结果作为查询条件时会报错,如;
SELECT T.inst_id
FROM BAPP_INST T
WHERE exists (select 1
from (WITH area(parent_area_id, area_id) AS (SELECT parent_area_id,
area_id
FROM fox_pboc_area
WHERE area_simple_name =
'廊坊市'
UNION ALL
SELECT b.parent_area_id,
b.area_id
FROM area a,
fox_pboc_area b
WHERE b.parent_area_id =
a.area_id)
SELECT area_id
FROM area) c
where T.INST_REGION = c.area_id
)

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

相关推荐