Skip to content
Advertisement

Selecting multiple rows from the same table with common column?

Have the following hypothetical table User_Mail_Info in Oracle DB

Primary key is User_Id,Mail_DL,DLId. There are other columns with the table as well.

How to retrieve the UserId ,given the list of (Mail_DL and DL Id) ?

Note: Mail_DL and DL_Id are not directly related. This is just hypothetical data

For eg. Input is

  • (DLA, 1), (DLB,2) – Output has to be User1
  • (DLA, 1), (DLB,2), (DLC,3) – Output has to be User2
  • (DLA, 1), (DLC,2), (DLB, 3) – Output has to be User3

Thanks in advance for helping out.

Advertisement

Answer

You can use aggregation and filtering. For the first example:

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