Using LIKE in an Oracle IN clause

前端 未结 9 1573
情深已故
情深已故 2020-12-06 09:49

I know I can write a query that will return all rows that contain any number of values in a given column, like so:

Select * from tbl where my_col in (val1, v         


        
9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-06 10:02

    Yes, you can use this query (Instead of 'Specialist' and 'Developer', type any strings you want separated by comma and change employees table with your table)

    SELECT * FROM employees em
        WHERE EXISTS (select 1 from table(sys.dbms_debug_vc2coll('Specialist', 'Developer')) mt where em.job like ('%' || mt.column_value || '%'));
    

    Why my query is better than the accepted answer: You don't need a CREATE TABLE permission to run it. This can be executed with just SELECT permissions.

提交回复
热议问题