Вы находитесь на странице: 1из 1

Chapter 3: Selecting 73

Heres what the equivalent SELECT looks like at this point:


SELECT t1.key_1,
t1.non_key_1,
t2.key_1,
t2.key_2,
t3.key_1,
t3.non_key_1
FROM ( t1 LEFT OUTER JOIN t2 ON t1.key_1 = t2.key_1 )
CROSS JOIN t3;
The full details of LEFT OUTER JOIN, CROSS JOIN, and other components
of the FROM clause will be explained in later sections. For the purposes of this
discussion, the FROM clause is processed first, separately from all the other
clauses, and simply returns a single result set for further processing by the rest
of the select.
Here is what the result set returned by the FROM clause looks like; each
row has been given a letter A, B, C, ... to identify it for the purposes of
discussion:
t1. t1. t2. t2. t3. t3.
key_1 non_key_1 key_1 key_2 key_1 non_key_1
===== ========= ===== ===== ===== =========
A 1 1 NULL NULL 3 333
B 1 1 NULL NULL 4 333
C 1 1 NULL NULL 5 0
D 1 1 NULL NULL 6 333

E 2 2 2 21 3 333
F 2 2 2 22 3 333
G 2 2 2 23 3 333

H 2 2 2 21 4 333
I 2 2 2 22 4 333
J 2 2 2 23 4 333

K 2 2 2 21 5 0
L 2 2 2 22 5 0
M 2 2 2 23 5 0

N 2 2 2 21 6 333
O 2 2 2 22 6 333
P 2 2 2 23 6 333

Note: Dont think for one second that the SQL Anywhere query processor
actually builds a result set like this for every select. If it did that, some queries
would take years to execute and would consume all the RAM and disk space
thats ever been manufactured. In reality, the query processor takes many short-
cuts, and does as little unnecessary work as possible in order to speed things up.
This step-by-step list is only a conceptual list, to explain how all the clauses fit
together and contribute to the final result.

Step 2: With the exception of aggregate function calls and NUMBER(*) calls,
the items in the select list are evaluated and appended to each row in the candi-
date result set. This may lead to some duplication between virtual columns and
select list items but that will only be temporary. Eventually all the virtual col-
umns will be eliminated, but they are still needed for a while.

Вам также может понравиться