Oracle
 sql >> Baza danych >  >> RDS >> Oracle

dynamiczna liczba warunku gdzie w Oracle sql

Wypróbuj

select something
  from somewhere
 where someColumn in (select regexp_substr('abc-def-xyz','[^-]+', 1, level) from dual
                     connect by regexp_substr('abc-def-xyz', '[^-]+', 1, level) is not null);

Aby uogólnić (biorąc pod uwagę, że pola są oddzielone znakiem „-”)

select something
  from somewhere
 where someColumn in (select regexp_substr(variable,'[^-]+', 1, level) from dual
                     connect by regexp_substr(variable, '[^-]+', 1, level) is not null);

Zasadniczo wynik podzapytania jest pokazany poniżej -

  SQL> select regexp_substr('abc-def-xyz','[^-]+', 1, level) value from dual
      connect by regexp_substr('abc-def-xyz', '[^-]+', 1, level) is not null;

VALUE                            
-------------------------------- 
abc                              
def                              
xyz  


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Jak warunkowo wybrać kolumnę w zapytaniu Oracle

  2. Czy użycie klauzuli RETURNING INTO jest szybsze niż oddzielnej instrukcji SELECT?

  3. jak zadeklarować SQLCA.SQLERRD?

  4. Jak uruchomić konkretny skrypt po połączeniu się z Oracle za pomocą szyn?

  5. Jak połączyć się z bazą danych Oracle za pomocą cx_Oracle z nazwą usługi i loginem?