dbTalk Databases Forums  

Intersect equivalent

comp.databases.xbase.fox comp.databases.xbase.fox


Discuss Intersect equivalent in the comp.databases.xbase.fox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
maani
 
Posts: n/a

Default Intersect equivalent - 12-23-2004 , 05:24 AM






aoa
how to intersect results of two queries? like i can use "intersect"
keyword in oracle.
consider the scenario:
find warehouses which have both types of contractors A and B.

now i want to write a query of type

select warehousecode
from warehouse,contractor
where warehouse.warehousecode=contractor.warehousecode
and contractortype ='A'

intersect

select warehousecode
from warehouse,contractor
where warehouse.warehousecode=contractor.warehousecode
and contractortype ='B'

i cant use AND or OR bcoz i only want those warehouses which must have
both type of contractors. hope to c some reply from u.(may b i m stuck
n cant write correct query,so plz join me )


Reply With Quote
  #2  
Old   
Alexandre Peshansky
 
Posts: n/a

Default Re: Intersect equivalent - 12-23-2004 , 10:50 AM






On 23 Dec 2004 03:24:36 -0800, "maani" <salman2k960 (AT) hotmail (DOT) com> wrote:

Quote:
aoa
how to intersect results of two queries? like i can use "intersect"
keyword in oracle.
consider the scenario:
find warehouses which have both types of contractors A and B.

now i want to write a query of type

select warehousecode
from warehouse,contractor
where warehouse.warehousecode=contractor.warehousecode
and contractortype ='A'

intersect

select warehousecode
from warehouse,contractor
where warehouse.warehousecode=contractor.warehousecode
and contractortype ='B'

i cant use AND or OR bcoz i only want those warehouses which must have
both type of contractors. hope to c some reply from u.(may b i m stuck
n cant write correct query,so plz join me )
Wouldn't that be simply
SELECT <whatever> FROM warehouse WHERE ;
warehousecode IN ;
(SELECT warehouse FROM contractor WHERE contractortype='A') ;
AND warehousecode IN ;
(SELECT warehouse FROM contractor WHERE contractortype='B')
?
--
[ When replying, remove *'s from address ]
Alexandre Peshansky, Systems Manager, RUH, NY


Reply With Quote
  #3  
Old   
Alexandre Peshansky
 
Posts: n/a

Default Re: Intersect equivalent - 12-23-2004 , 10:51 AM



On Thu, 23 Dec 2004 11:50:30 -0500, I wrote:

Quote:
On 23 Dec 2004 03:24:36 -0800, "maani" <salman2k960 (AT) hotmail (DOT) com> wrote:

aoa
how to intersect results of two queries? like i can use "intersect"
keyword in oracle.
consider the scenario:
find warehouses which have both types of contractors A and B.

now i want to write a query of type

select warehousecode
from warehouse,contractor
where warehouse.warehousecode=contractor.warehousecode
and contractortype ='A'

intersect

select warehousecode
from warehouse,contractor
where warehouse.warehousecode=contractor.warehousecode
and contractortype ='B'

i cant use AND or OR bcoz i only want those warehouses which must have
both type of contractors. hope to c some reply from u.(may b i m stuck
n cant write correct query,so plz join me )

Wouldn't that be simply
SELECT <whatever> FROM warehouse WHERE ;
warehousecode IN ;
(SELECT warehouse FROM contractor WHERE contractortype='A') ;
AND warehousecode IN ;
(SELECT warehouse FROM contractor WHERE contractortype='B')
?
Oops... It should be

SELECT <whatever> FROM warehouse WHERE ;
warehousecode IN ;
(SELECT warehousecode FROM contractor WHERE contractortype='A') ;
AND warehousecode IN ;
(SELECT warehousecode FROM contractor WHERE contractortype='B')

--
[ When replying, remove *'s from address ]
Alexandre Peshansky, Systems Manager, RUH, NY


Reply With Quote
  #4  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: Intersect equivalent - 12-23-2004 , 05:00 PM



"maani" <salman2k960 (AT) hotmail (DOT) com> wrote:

Quote:
aoa
how to intersect results of two queries? like i can use "intersect"
keyword in oracle.
consider the scenario:
find warehouses which have both types of contractors A and B.

now i want to write a query of type

select warehousecode
from warehouse,contractor
where warehouse.warehousecode=contractor.warehousecode
and contractortype ='A'

intersect

select warehousecode
from warehouse,contractor
where warehouse.warehousecode=contractor.warehousecode
and contractortype ='B'

i cant use AND or OR bcoz i only want those warehouses which must have
both type of contractors. hope to c some reply from u.(may b i m stuck
n cant write correct query,so plz join me )
You have not specified your requirement very clearly, nor have
you shown your realtions' attributes.

I *think* you want a list of warehousecode where there are
contractortype of both "A" and "B" in contractor for that
warehousecode.

select warehousecode
from warehouse
where
warehousecode in
(select warehouse.warehousecode from contractor
where contractortype="A")
and
warehousecode in
(select warehouse.warehousecode from contractor
where contractortype="B")

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.


Reply With Quote
  #5  
Old   
maani
 
Posts: n/a

Default Re: Intersect equivalent - 12-27-2004 , 10:23 PM



aoa
yes i think the "in/AND" logic works for intersection,but answer to my
question then becomes "no intersect clause in vfp". thanx .happy new
year to all.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.