I have two tables like these:
Table 1
id codpr price
1 456 6300.98
2 321 540.00
3 123 1275.90
...
Table 2
id tb1id codpr price
1 2 321 540.00
2 2 453 1345.90
3 2 125 6570.80
...
Table 1 contains historic transactions of codprs. Table 2 contains extended transactions associated with a single movement (for example: trans id 2 is a extended one).
When there is a multi-transaction, Table 2 contains all codprs, including the Table 1 codpr.
So the result needs to reflect lines from Table 1 only when there is no related lines in Table 2. When Table 2 contains related records, The result should yield only the lines in Table 2.
The result of the example would look like this :
cid codpr price
1 456 6300.98
2 321 540.00
2 453 1345.90
2 125 6570.80
3 123 1275.90
...
(cid is not necessary. It appears only for control).
I know how join two tables and select rows with matching in another table but I don’t know how discriminate the output.
mhbeyle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.