|
|
Re: How to avoid replication of rows while making the joins between two tables? [message #374949 is a reply to message #374947] |
Fri, 13 July 2001 07:15 |
Cindy
Messages: 88 Registered: November 1999
|
Member |
|
|
Ways to avoid cartesian product is to use subquery or include valid join conditions.
Example subquery:
SELECT column1, column2, column3, column4
FROM table_name1 t1
WHERE (t1.column2, t1.column3) IN (SELECT t2.column2, t2.column3 FROM table_name2 t2
WHERE t1.column1 = t2.column2
AND column1 = 605;)
AND MIN(t1.column4) > (SELECT MIN(t2.column4) FROM table_name2 t2 WHERE t1.column1 = t2.column2 AND t2.column1 = 605;)
AND t1.column1 <> 605;
|
|
|