Skip to content
Advertisement

Oracle SQL String Contains a value from another Table

I am looking to find a way to add a where clause where a string in one table contains data from a column in another table.

Select
ID,
Name,
Group,
List
From EDG
Where
List Like '% (Select(Column X) FRom Diag)%'

I’m looking for something that would work like you see above. There are no columns to join on for the tables, it is just List in EDG can contain values from column X in Diag.

Any help would be appreciated.

Thanks,

Advertisement

Answer

Then you can join, because any statement that results in a truth can be used for join:

Select
  E.ID,
  E.Name,
  E.LGroup,
  E.List
From 
  EDG E
  INNER JOIN Diag D
  ON
    E.List Like '%'||D.X||'%'

Inner join will result in only rows where List string contains X

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement