hello
ByteMizer and JonFer gave great advice that helped me with an SQL problem a few weeks ago. I now have a related problem that I've been struggling with for a week. I can get it to work, but VERY SLOWLY. In the example I describe, I show tblMain with 5 data columns (C1 to C5), but the actual tblMains I am working with have 10 data columns and hundreds of thousands of rows.
Consider two tables... [tt]
tblMain tblPairs
ID C1 C2 C3 C4 C5 inp outp
1 28 26 11 56 50 56 11
2 28 44 49 49 11 50 13
3 49 44 13 44 44 49 44
4 11 49 49 44 28 44 49
5 28 13 28 56 11 28 26
6 13 11 56 28 26 26 28
7 49 49 50 49 44 13 50
..... 11 56
800000 49 11 11 13 56
I need a query that will SELECT all rows in tblMain that follow this pattern...
In the tblMain shown, row 1 has values 28, 26, 11, 56, 50.
When REVERSED, we get... 50, 56, 11, 26, 28.
Replacing values from tblPairs we get 13, 11, 56, 28, 26
[/tt]
But this is just row 6 of tblMain, so I DON'T want to select it because it 'matches' row 1. Similarly, row 7 is not selected because it 'matches' the earlier row 3. In the tblMain shown, I would SELECT only rows 1, 2, 3, 4, 5, 800000.
I tried to do this by creating a VBA function that would look up values in tblPairs like.... F(56) = 11. Then I used SQL to INNER JOIN tblMain as M1 to tblMain as M2 ON M1.C1 = F(M2.C5) AND M1.C2 = F(M2.C4) AND ...etc. This work, but is exceedingly slow on my actual VERY LARGE table.
I'm really hoping there is a nice way to do this, hopefully just using SQL, that is fast!
many thanks
Vicky C.
ByteMizer and JonFer gave great advice that helped me with an SQL problem a few weeks ago. I now have a related problem that I've been struggling with for a week. I can get it to work, but VERY SLOWLY. In the example I describe, I show tblMain with 5 data columns (C1 to C5), but the actual tblMains I am working with have 10 data columns and hundreds of thousands of rows.
Consider two tables... [tt]
tblMain tblPairs
ID C1 C2 C3 C4 C5 inp outp
1 28 26 11 56 50 56 11
2 28 44 49 49 11 50 13
3 49 44 13 44 44 49 44
4 11 49 49 44 28 44 49
5 28 13 28 56 11 28 26
6 13 11 56 28 26 26 28
7 49 49 50 49 44 13 50
..... 11 56
800000 49 11 11 13 56
I need a query that will SELECT all rows in tblMain that follow this pattern...
In the tblMain shown, row 1 has values 28, 26, 11, 56, 50.
When REVERSED, we get... 50, 56, 11, 26, 28.
Replacing values from tblPairs we get 13, 11, 56, 28, 26
[/tt]
But this is just row 6 of tblMain, so I DON'T want to select it because it 'matches' row 1. Similarly, row 7 is not selected because it 'matches' the earlier row 3. In the tblMain shown, I would SELECT only rows 1, 2, 3, 4, 5, 800000.
I tried to do this by creating a VBA function that would look up values in tblPairs like.... F(56) = 11. Then I used SQL to INNER JOIN tblMain as M1 to tblMain as M2 ON M1.C1 = F(M2.C5) AND M1.C2 = F(M2.C4) AND ...etc. This work, but is exceedingly slow on my actual VERY LARGE table.
I'm really hoping there is a nice way to do this, hopefully just using SQL, that is fast!
many thanks
Vicky C.