Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Some Help with Select statement
Message
De
22/09/2003 05:32:41
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00830332
Message ID:
00831002
Vues:
23
>>>>>Hi Kevin,
>>>>>
>>>>>>... the Times AND the Sunday Times and NO other papers.
>>>>>
>>>>>
>>>>> WHERE INLIST(ItemId, ID_SUNDAYTIMES, ID_TIMES); && <-- this is OR
>>>>>   ...
>>>>>
>>>>>
>>>>>Fabio
>>>>
>>>>So it is :-)
>>>>
>>>>
WHERE ItemId = ID_SUNDAYTIMES OR ItemId = ID_TIMES
>>>>
>>>>Thanks for the correction.
>>>>
>>>>Kev
>>>Kev,
>>>Unfortunately that still does and OR not and AND across multiple records which is what I need.
>>
>>Oops, I'm not with it today.
>>
>>Do you have to achieve this in 1 select?
>>
>>Kev
>
>Ideally yes.

Hang on a minute, try this:

For Sunday Times and The Times:
SELECT CustId ;
  FROM Sub;
 WHERE ItemId = 1;
   AND CustId NOT IN (SELECT CustId FROM Sub WHERE ItemId != 1 AND ItemId != 2);
 UNION;
SELECT CustId;
  FROM Sub;
 WHERE ItemId = 2;
   AND CustId NOT IN (SELECT CustId FROM Sub WHERE ItemId !=1 AND ItemId !=2) 
Then, for The Times, Sunday Times and the Daily Telegraph, just to prove concept.
SELECT CustId ;
  FROM Sub;
 WHERE ItemId = 1;
   AND CustId NOT IN (SELECT CustId FROM Sub WHERE ItemId != 1 AND ItemId != 2 AND ItemId !=3);
 UNION;
SELECT CustId;
  FROM Sub;
 WHERE ItemId = 2;
   AND CustId NOT IN (SELECT CustId FROM Sub WHERE ItemId !=1 AND ItemId !=2 AND ItemId !=3);
 UNION;
SELECT CustId;
  FROM Sub;
 WHERE ItemId = 3;
   AND CustId NOT IN (SELECT CustId FROM Sub WHERE ItemId !=1 AND ItemId !=2 AND ItemId !=3)
Does that work?

Kev
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform