Hi,
A Cartesian join produces the mix of all records of one table with all
records of the second table. So, if tableA has one field f1 with 3 records,
with values 10, 20, 30; while tableB, one field g1, two records with values
1 and 2, then the join:
SELECT tableA.f1, tableB.g1
FROM tableA, tableB
produces 3*2 = 6 records:
10 1
10 2
20 1
20 2
30 1
30 2
An inner join does LOGICALLY the same, but keep only those mix that
evaluates the ON clause to True. You are NOT limited to comparison with =,
any logical expression that is a Boolean result (true, false, null) can do.
As example:
SELECT tableA.f1, tableB.g1
FROM tableA INNER JOIN tableB ON tableA.f1 >= 10*tableB.g1
10 1
20 1
20 2
30 1
30 2
note that (10 2) is not present anymore since the ON clause, tableA.f1 >=
10*tableB.g1, is false with f1=10 and g1=2.
That was the theory.
In OUR actual case, the second table, Iotas, has values from 0 to 999, so,
if a mix is such that startingSequence + iota > endingSequece, then, we
DON'T want to keep that "mix" between the table of sequences and the table
iotas. So our ON clause is :
ON StartingSequence + iota <= endingSequence
or, simple mathematical arrangement,
ON iota <= EndingSequence-StartingSequence
which could allow the use of the index on Iotas.iota if there is one, while
the first formulation is unlikely to allow it. (A column involved in a
computed expression, like + or -, is unlikely to see its index used).
Everything else is just question of syntax, or to accommodate the
presentation.
StartingSequence+Iota will supply the sequence:
StartingSequence+0
StartingSequence+1
StartingSequence+2
....up to...
StartingSequence+m = EndingSequence
Hoping it may help,
Vanderghast, Access MVP
Aron said:
Can you explan me this query so i can tweak it a little bit
this query covers only 85% of the book serias
Michel Walsh said:
Hi,
If you have a driver table, Iotas, one field, Iota, with values from 0
to,
say, 999, then
SELECT myTable.[From Serias]+ Iotas.Iota, [BookCase#]
FROM myTable INNER JOIN Iotas ON Iotas.Iota <=myTable.[ToSerias] -
myTable.[From Serias]
should do.
Hoping it may help,
Vanderghast, Access MVP
No
This would not fill out the blanks
:
Dear Aron:
Could it be as simple as this:
SELECT DISTINCT [From Serias], [BookCase#]
FROM [library index]
ORDER BY [From Serias]
Tom Ellison
a library with nearly 10000 books (or series) in 80 Book cases
each book has a uniqe id number
i have a library index table with 3 columns
From Serias To Serias BookCase#
1 3 1
4 5 2
6 7 4
8 8 1
9 9 4
10 14 3
15 16 2
i need for each serias the exact bookcase number
the rasult should be like this
Serias BookCase#
1 1
2 1
3 1
4 2
5 2
6 4
7 4
8 1
9 4
10 3
11 3
12 3
13 3
14 3
15 2
16 2