how to pass a variable in WHERE IN clause of oracle sql?

前端 未结 3 967
一向
一向 2021-01-13 06:10

Hi
I have a variable $1 which hold comma separated email addresses like john@example.com,pat@example.com . I wish to pass this variable in a where clause like

         


        
3条回答
  •  死守一世寂寞
    2021-01-13 07:00

    A simple workaround, which might be good enough in your case (but is not performant), is to use LIKE instead:

    select * from something where $1 like '%,'||mycolumn||',%';
    

    $1 is your comma separated list, as a string, with a comma prepended and appended, e.g.

    ,foo@bar.com,ammoq@ammoq.com,onemore@whatever.com,
    

提交回复
热议问题