two tables in database, similar structure below.
-I need the list of elements from TABLE1 where P1 matches S3 and at the same time P2 matches S2.
+ TABLE1 + + TABLE2 +
+---------+---------+---------+ +---------+---------+---------+
| P1 | P2 | P3 | + S1 | S2 | S3 |
+---------+---------+---------+ +---------+---------+---------+
| A | B | C | | P | B | A |
| B | B | C | | A | G | T |
| Z | K | R | | T | M | T |
| T | S | L | | M | K | Z |
| W | W | W | | W | W | W |
+---------+---------+---------+ +---------+---------+---------+
so, as a result I shall get:
+ RESULT +
+---------+---------+---------+
| P1 | P2 | P3 |
+---------+---------+---------+
| A | B | C |
| Z | K | R |
| W | W | W |
+---------+---------+---------+
the question : what is the oracle query that does this join, compare and match operations.
Note: using a loop is discouraged.
Thanks in advance…
You can use
INNER JOINto combine both tables.CLICK here for more type of Joins (Oracle Docs)