Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to use SQL Select UNION with TOP
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01303352
Message ID:
01303979
Views:
14
>>>>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
Previous
Reply
Map
View

Click here to load this message in the networking platform