|
View previous topic :: View next topic
|
| Author |
Message |
ksathishkumar4u Currently Banned New User
Joined: 29 May 2006 Posts: 0
|
|
|
|
I need a query to do the following in two tables say AAA and BBB
AAA has columns a,b,c,d,e,f,g,h
BBB has columns h,i,j,k
I have to fetch rows such that a,b,c,d,e,f,g should be equal
h should be different
i,j,k -any one of the values shopuld differ
example
a b c d e f g h i j k
1 2 3 4 5 6 7 8 9 10 11
1 2 3 4 5 6 7 17 9 10 14
or
a b c d e f g h i j k
1 2 3 4 5 6 7 8 9 10 11
1 2 3 4 5 6 7 17 9 14 11
or
a b c d e f g h i j k
1 2 3 4 5 6 7 8 9 10 11
1 2 3 4 5 6 7 17 14 10 11
Thanks in advance |
|
| Back to top |
|
 |
red_roses
New User

Joined: 31 Oct 2005 Posts: 27
|
|
|
|
| you say a,b,c,d,e,f,g should be equal ... equal to what.. as per your description BBB has none of the rows from a to g. so on what are you going to match..???? |
|
| Back to top |
|
 |
priyesh.agrawal
Senior Member

Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
I hope, I understood what you wanted to convey... else excuse me for wasting your time...
| Code: |
SELECT * FROM
(SELECT * FROM
(SELECT * FROM AAA, BBB WHERE AAA.H = BBB.H)
GROUP BY A,B,C,D,E,F,G HAVING COUNT(*) >1)
GROUP BY I,J HAVING COUNT(*) >1
UNION
SELECT * FROM
(SELECT * FROM
(SELECT * FROM AAA, BBB WHERE AAA.H = BBB.H)
GROUP BY A,B,C,D,E,F,G HAVING COUNT(*) >1)
GROUP BY J,K HAVING COUNT(*) >1
UNION
SELECT * FROM
(SELECT * FROM
(SELECT * FROM AAA, BBB WHERE AAA.H = BBB.H)
GROUP BY A,B,C,D,E,F,G HAVING COUNT(*) >1)
GROUP BY I,K HAVING COUNT(*) >1 |
|
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|