PL/SQL query IN comma deliminated string

前端 未结 10 2169
攒了一身酷
攒了一身酷 2021-01-02 04:46

I am developing an application in Oracle APEX. I have a string with user id\'s that is comma deliminated which looks like this,

45,4932,20,19
10条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-02 05:33

    An easier solution is to use instr:

    SELECT * FROM users u 
    WHERE instr(',' || :P5_USER_ID_LIST ||',' ,',' || u.user_id|| ',', 1) !=0;
    

    tricks:

    ',' || :P5_USER_ID_LIST ||','
    

    to make your string ,45,4932,20,19,

    ',' || u.user_id|| ','
    

    to have i.e. ,32, and avoid to select the 32 being in ,4932,

提交回复
热议问题