SQL 函数 instr的用法

INSTR(C1,C2,I,J) 在一个字符串中搜索指定的字符,返回发现指定的字符的位置;

C1    被搜索的字符串

C2    希望搜索的字符串

I     搜索的开始位置,默认为1

J     出现的位置,默认为1

SQL> select instr("abcde",'b');

 

结果是2,即在字符串“abcde”里面,字符串“b”出现在第2个位置。如果没有找到,则返回0;不可能返回负数 

http://dmvoiptt.oracle.com.cn/redirect.php?tid=137792&goto=lastpost

SQL> select * from grp_mem;

NAME                 ID

-------------------- ----------

group1               1.2

SQL> select * from mem_info;

 

        ID IP

---------- --------------------

         1 10.10.20.1

         1 10.10.20.2

         2 10.20.20.2

         2 10.20.20.1

         3 10.30.20.1

 

SQL> select a.name,b.ip from grp_mem a,mem_info b

 

      where a.name='group1' and instr(a.id,b.id)>0;

 

NAME                 IP

-------------------- --------------------

group1               10.10.20.1

group1               10.10.20.2

group1               10.20.20.2

group1               10.20.20.1

 

SQL>

posted @ 2012-03-26 11:47  憶言  阅读(1539)  评论(0编辑  收藏  举报