|
|
|
Re: select data which does not in join condition [message #20670 is a reply to message #20651] |
Wed, 12 June 2002 18:10 |
Su
Messages: 154 Registered: April 2002
|
Senior Member |
|
|
No doubt, I agree with Vikas (what I just thought to give the answer, he gave it). The MINUS operator is just effecient and quicker to retrieve the data you want. But, just to be sure, as you said, if the result should be just in reverse to the equi-join you mentioned, then the way Vikas mentioned does not achieve the result you want.
If both tables are having same structure and the number of columns you are retrieving is same, then try the following out adding little modification to the Vikas's logic.
SELECT * FROM TABLEA A
MINUS
SELECT * FROM TABLEA A, TABLEB B WHERE A.COLUMN1 = B.COLUMN1;
The first SELECT returns all the rows existing in tablea (lets say 100) and the second SELECT returns only the rows those are matching with each other (lets say 65), so the final outcome of this combined query should return (100 minus 65) 35 rows of nonmatching data. Remember, when you use MINUS, the first SELECT should return more number of rows than the ones return by latter to get the right outcome. Hope you got my point. Check it out. Good luck :)
|
|
|
|