一个表 table1 (id,hydm,jsdm) 如下:
id  hydm        jsdm
1   A000   0100','0200','0300','0400','0500
2   0100    
3   0200
4   0300
-----------------------------------------
现在我想这样操作
select * from table1 where hydm in (
select ''''||jsdm||'''' from table1 where hydm = 'A000')
为什么得不到任何记录?

解决方案 »

  1.   

    select * from table1 where ''''||hydm||'''' in (
    select ''''||jsdm||'''' from table1 where hydm = 'A000')
      

  2.   

    select ''''||jsdm||'''' from table1 where hydm = 'A000'
    看到的结果是:'0100','0200','0300','0400','0500'
    实际上这是一整个字符串,可以表示为:''0100','0200','0300','0400','0500''
    in 需要'0100' '0200'等 都是单个的字符串,而这个查询结果实际上是一个字符串 
    所以IN是无法查出来的
      

  3.   

    select * from table1 where instr(
    (select jsdm from table1 where hydm = 'A000'),hydm)>0