Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to make such query?
Message
From
26/12/2005 12:10:23
 
 
To
26/12/2005 11:45:56
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01080746
Message ID:
01080837
Views:
20
Thank you Cetin

That explains why I thought that HAVING was necessary and WHERE would fail
_____________________
>Gregory,
>Version in title says VFP9. Some behaviors of SQL are changed. 3rd would return 1 row under VFP9 and 0 under VFP6.
>Cetin
>
>>Fabio,
>>
>>thanks for the sequence,
>>
>>I am, however puzzled
>>
>>>>Shouldn't that be HAVING instead of WHERE ?
>>>>
>>>No. They are equal on this context.
>>...
>>>>So, since no records have (fk is null), no records will pass the WHERE clause. Look at the output of (3)
>>>
>>>Have you looked the (3) ? It return one row.
>>
>>
>>Why, (vfp6 sp5) does (3) return an empty set over here and 1 row on your computer ? Something I am missing ?
>>ie, HAVING = 1 row, WHERE = zero rows
>>
>>>>
>>>>create cursor Customer (c_id I)
>>>>	insert into Customer values(1)
>>>>	insert into Customer values(2)
>>>>	
>>>>	Create cursor Orders( ord_id I, Ord_c_id I )
>>>>	
>>>>	insert into Orders values (22, 2)
>>>>	insert into Orders values (24, 2)
>>>>	
>>>>	&& find customers without order(s)
>>>>	
>>>>	&& (1)
>>>>	select	c_id ;
>>>>		from Customer ;
>>>>		into cursor tmp1 ;
>>>>		where	( not exists ;
>>>>					(select * from Orders where (Ord_c_id = c_id) ) ;
>>>>				);
>>>>				
>>>>	brow
>>>>	
>>>>	&& (2) left join, with having
>>>>	select	c_id, ;
>>>>			ord_id ;
>>>>		from Customer ;
>>>>			left join Orders on (Ord_c_id = c_id) ;
>>>>		into cursor tmp2 ;
>>>>		having ( ord_id is null )
>>>>	
>>>>	brow
>>>>	
>>>>	
>>>>	&& (3) left join, with where
>>>>	select	c_id, ;
>>>>			ord_id ;
>>>>		from Customer ;
>>>>			left join Orders on (Ord_c_id = c_id) ;
>>>>		into cursor tmp3 ;
>>>>		where ( ord_id is null )
>>>>	
>>>>	brow
>>>>
>>>
>>>Fabio
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform