Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to use SQL Select UNION with TOP
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01303352
Message ID:
01303979
Vues:
15
>>>>select PK from table inner join (select TOP 50 * from MyTable where PK_VAL > nVar Order by PK_VAL) TopSQL on ... ;
>>>>UNION ALL ;
>>>>select TOP 50 * from MyTable where PK_VAL < nVar Order by PK_VAL DESC
>>>>
>>>>Would this idea work too?
>>>
>>>I will try and compare with Sergey's approach. Thank you.
>>
>>So, which approach worked?
>
>Sergey's suggestion worked perfectly. But I thank you for your suggestion too; I have not had a chance to try it since I stopped at success <g>.

I guess it should have also work. But I was thinking that Sergey's solution is probably more efficient since it doesn't involve a JOIN.

It's actually very nice to use select * from (select...), I don't see this syntax suggested here often.

But just for curiosity sake I would appreciate if you can try both approaches and may be even compare the speed.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform