Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP 5.0 & 6.0 - Nested SELECT's
Message
 
À
17/02/1999 11:35:09
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00188396
Message ID:
00188450
Vues:
28
>Could you be so kind and type the code for me?
>I have tried several things and I still can't get it right.
>Thank you again
>
>
>>>These two lines run fine if I run one after the other.
>>>
>>>SELECT * FROM CUSTOMER WHERE MAXORDAMT > 50000
>>>
>>>SELECT * FROM CUSTOMER WHERE ALLT(COUNTRY) = 'USA'
>>>
>>>
>>>
>>>If I try to nest them, they don't run, what am I doing wrong?
>>>SELECT * FROM CUSTOMER ;
>>> WHERE MAXORDAMT > 50000 AND ;
>>> (SELECT * FROM CUSTOMER WHERE ALLT(COUNTRY) = 'USA')
>>>
>>>
>>>Thank you in advance
>>
>>Your subquery syntax is incorrect. First of all, after the AND in your where clause, and before the subquery, you need V1.< field > [NOT] IN. Secondly, your subquery should only return one column, the Customer field which matches the field in V1.
>>
>>HTH,
>>Rich.

I don't know your field names, but something like this:
SELECT * FROM CUSTOMER ;
	WHERE MAXORDAMT > 50000 AND ;
	CustKey IN (SELECT CustKey FROM CUSTOMER WHERE ALLT(COUNTRY) = 'USA')
or you can say "NOT IN" instead of "IN", if you want only non-USA customers.

Note, I put a couple HTML codes before and after the select commands to make the message look correct in your browser. Just saying this so you don't mistake them as part of the SELECT statement.

HTH,
Rich.
Rich Addison, Micro Vane, Inc., Kalamazoo, MI
Relax, don't worry, have a homebrew.
- Charlie Papazian, The New Complete Joy of Home Brewing
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform