Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
UNION SELECT... please correct me
Message
De
27/10/1998 21:56:42
 
 
À
27/10/1998 05:25:06
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00150818
Message ID:
00151364
Vues:
18
>Hi
>I want to receive 2 records from the table between which the variable is located.
>
>My code:
>SELECT TOP 1 * ;
>FROM myDatabase!myTable ;
> WHERE myTable.cod = pCod ;
> AND myTable.price >=pPrice ;
> UNION ;
> SELECT TOP 1 *;
> FROM myDatabase!myTable;
> WHERE myTable.cod = pCod ;
> AND myTable.price <=pPrice ;
>ORDER BY mytable.price ;
>INTO CURSOR curPrice
>
>I receive error message... What the problem ?... OR I do't use TOP 1 AND UNION ?
>Thanks for your messages.
>Denis.

ORDER BY in a UNION refers to the entire result set. You need to do to separate querues then join them
select top 1 *, from .... into cursor C1 nofilter
select top 1 *, from .... into cursor C2 nofilter
select * from c1 union all select * from c2

HTH
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform