Yes, Mike's solution is much simpler and will work if A, B, and C all share the same ID value. <br>
<br>
However, I believe the problem is that table C is really defined as (Assassin - Please confirm):<br>
<br>
BadProduct (B.ID%TYPE)<br>
Worker (A.ID%TYPE)<br>
NewProduct (B.ID%TYPE)<br>
ReplacedBy (A.ID%TYPE)<br>
ID<br>
<br>
If Worker <> ReplacedBy and/or BadProduct <> NewProduct within any given row, then I believe you would have to use my query (or something like it) in order to extract the names of all clients and products involved.<br>
<br>
For instance, if Table A contains rows<br>
<br>
ID Name<br>
1 Smith<br>
2 Jones<br>
<br>
<br>
and Table B contains<br>
<br>
ID Name<br>
1 Metal Rotor<br>
2 Plastic Rotor<br>
3 Carbon Rotor<br>
<br>
<br>
and Table C contains<br>
<br>
ID BadProduct Worker NewProduct ReplacedBy<br>
1 1 1 2 2<br>
<br>
I believe Mike's query would look something like (Mike - is this what you meant or did I misread you?) :<br>
<br>
SQL> select a.name "1st Worker", <br>
b.name "1st Part", <br>
a.name "2nd Worker", <br>
b.name "2nd Part"<br>
from a,b,c<br>
where c.id = 1<br>
and c.id = a.id<br>
and c.id = b.id;<br>
<br>
1st Worker 1st Part 2nd Worker 2nd Part<br>
-------------------- -------------------- -------------------- --------------------<br>
Smith Metal Rotor Smith Metal Rotor<br>
<br>
which would not be a correct response here.<br>
<br>
That is why my query includes multiple references to the same table. In this case, my query/response looks like:<br>
<br>
SELECT replacement.id,<br>
old_product.name "1st Part",<br>
old_worker.name "1st Worker",<br>
new_product.name "2nd Part",<br>
new_worker.name "2nd Worker"<br>
FROM a old_worker,<br>
a new_worker,<br>
b old_product,<br>
b new_product,<br>
c replacement<br>
WHERE<br>
replacement.id = 1<br>
AND replacement.worker = old_worker.id<br>
AND replacement.badproduct = old_product.id<br>
AND replacement.replacedby = new_worker.id<br>
AND replacement.newproduct = new_product.id<br>
<br>
ID 1st Part 1st Worker 2nd Part 2nd Worker<br>
--------- -------------------- -------------------- -------------------- --------------------<br>
1 Metal Rotor Smith Plastic Rotor Jones<br>
<br>
<br>
Assassin - do either of these solve your problem?<br>
(Sorry about the formatting, but blank spaces keep getting eliminated and TAB doesn't work here!)