有一张表 
项目id 申请人id
1 22,24,67
2 33,67
3 45,67,89
我想查出id为67的人申请的所有项目id应该怎样写sql呢?

解决方案 »

  1.   

     假设:
        项目id:   pid
       申请人id: id
       一张表 :   table1
    代码如下:select pid
      from table1
    where instr(','||id||',',',67,')>0;
      

  2.   

    select * from 有一张表 where Instr(',' || 申请人id || ',', ',67,') > 0
      

  3.   

    select * from table_name 
    where application_id like '%67%'
      

  4.   

    可以使用instr,如1楼
    注意,如果列上加入了运算(包括函数),是不能使用上普通索引(除非建立函数索引)