Resolved: SQL Query to Check presence of a Column of one table and a Column of another table as pair on a third table?


Table structure
  1. Table1.col1 contains some Names and Table2.col2 is a datetime field.
  2. Table 3 has both the two columns.
  3. I’m using Oracle database.
  4. Table3 is the master table which has more than a billion records.
  5. Table1 and Table2 has no relation/link.

Expected output from above image:
I need a query to fetch all those pairs of table1.column1 and table.column2 which are not present in Table3 against the respective columns Col1 and Col2. Any Logic or an approach will be helpful.
Edit – The question is complete in itself because it’s only looking for a logic or a pseudocode from the provided data.


A reproducible example would help.
My guess from your description is that you want to create a Cartesian product of table1 and table2 and minus table3 from that Cartesian product
select t3.column1, t3.column2
  from table3 t3
select t1.column1, t2.column2
  from table1 t1
       cross join table2 t2
If that is not what you are looking for, providing the reproducible example would be quite helpful.

If you have better answer, please add a comment about this, thank you!