Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Puzzle
Message
From
28/11/2003 08:15:08
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
28/11/2003 07:42:26
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00854130
Message ID:
00854179
Views:
18
Fabio,

the proble is in (scematic)
From CurA;
inner join CurB on CurA CompareWith CurB;
inner join CurC on CurA CompareWith CurC
Since you join CurC with CurB and the Result with CurA
you may run into problems if you compare at CurC joins ON clause with CurA.

What I have done is to modify the SELECT SQL in a way the the cursors on both "sides" of JOIN are used in the on clause.

I have had problems like that with outer joins and I'm not sure what happens in plain inner joins, but to me it's a good idea to do things in a way that works everywhere.


Have nice weekend

Agnes

>Hi Agnes,
>
>Write
> T1 INNER JOIN T2 ON joinCondition(T1,T2) WHERE filterCondition(T1,T2)
>is equivalent to write
> T1 INNER JOIN T2 ON joinCondition(T1,T2) AND filterCondition(T1,T2)
>
>and i use the last form because it is clearer ( for me ), and i'm sure that it
>is optimized.
>
>VFP optimize the where clause, and trasform the first on the second;
> BUT VFP not optimize the HAVING clause
>
>try this:
>
>CLEAR
>SET TALK OFF
>CREATE CURSOR T1 (id I DEFAULT RECNO())
>CREATE CURSOR T2 (fid I DEFAULT T1.id,condition I DEFAULT RAND()*100)
>FOR K=1 TO 10
>	APPEND BLANK IN T1
>	FOR j=1 TO 500
>		 APPEND BLANK IN T2
>	NEXT
>NEXT
>SYS(3054,11)
>
>tz=SECONDS()
>SELECT T1.id, T2.condition FROM T1 ;
>	JOIN T2		ON T2.fid =T1.id ;
>	JOIN T2 T3	ON T3.fid =T1.id ;
>	WHERE T2.condition>90 AND T3.condition<10 ;
>	INTO CURSOR dummyWhere
>? SECONDS()-tz
>
>tz=SECONDS()
>SELECT T1.id, T2.condition FROM T1 ;
>	JOIN T2		ON T2.fid =T1.id AND T2.condition>90 ;
>	JOIN T2 T3	ON T3.fid =T1.id AND T3.condition<10 ;
>	INTO CURSOR dummyJoin
>? SECONDS()-tz
>
>tz=SECONDS()
>SELECT T1.id, T2.condition FROM T1 ;
>	JOIN T2		ON T2.fid =T1.id ;
>	JOIN T2 T3	ON T3.fid =T1.id ;
>	HAVING T2.condition>90 AND T3.condition<10 ;
>	INTO CURSOR dummyHaving
>? SECONDS()-tz
>
>
>Fabio
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform