![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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 ) |
#3
| |||
| |||
|
|
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') ? |
#4
| |||
| |||
|
|
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 ) |
#5
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |