0

我正在尝试执行以下查询:

select * from trgdms.src_stm where trim(src_stm_code) in (select concat (concat('''', trim(replace(processed_src_sys_cd,',',''','''))),'''' ) from trgdms.batch_run_log where src_stm_cd_or_hub_cd='CTR' and file_process_dt='2015-06-19' and batch_id=42);

表 trgdms.src_stm 的 src_stm_code 列具有 T19、T68、T73 等值。当我单独运行内部查询时,我确实得到了正确的结果:

select concat (concat('''', trim(replace(processed_src_sys_cd,',',''','''))),'''' ) from trgdms.batch_run_log where src_stm_cd_or_hub_cd='CTR' and file_process_dt='2015-06-19' and batch_id=42

结果:'T19','T68','T73'

想知道是否有人在 db2 中使用过类似的东西?

4

1 回答 1

0

concat从内部查询中删除部分。连接值时,生成的值列表将被视为字符串,查询不会返回任何结果。

select * from trgdms.src_stm where trim(src_stm_code)
in (select trim(replace(processed_src_sys_cd,',',''',''')) from trgdms.batch_run_log 
    where src_stm_cd_or_hub_cd='CTR' and file_process_dt='2015-06-19' and batch_id=42);
于 2015-10-06T16:59:41.147 回答