sql - Oracle Get Records where String not present as Sub string in other rows?

标签 sql oracle plsql substring

嗨,这是我的问题:-

Value
-----
ABCDE
ABCD
ABC
ABF
ABFG

结果应该是:ABCDE & ABFG

以上不是同一列中没有重复出现的任何其他字符串的子串

最佳答案

你可以这样做:

select *
from my_table t1
where not exists (
  select 1 from my_table t2
  where t1.value <> t2.value 
    and t2.value like '%' || t1.value || '%'
)

关于sql - Oracle Get Records where String not present as Sub string in other rows?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53949826/

相关文章:

sql - Oracle 克隆用户的方法

甲骨文 : Export select statement result set as INSERT SQL Statements similar to SQL developer export

mysql - SQL INTERVAL 不适用于 openshift

sql-server - 在 SSIS 包中存储密码

c++ - Oracle ODBC 插入失败,没有任何错误诊断

oracle - 在存储过程中使用 EXECUTE IMMEDIATE 执行 DML 语句

sql - 保持多个数据库之间的引用完整性

sql - BigQuery 重复的rank()数字

sql - PostgreSQL - 数据错误 : invalid input syntax for type numeric: "Product"

mysql - 在数据库中存储大质数