Search This Blog

Friday, January 7, 2011

Select a range from oracle, mysql

I talked about how to select first/top n rows from oracle, mysql, and ms sql server. How do we get the range, say from m to n, where m < n?

Oracle
select id, age from (select id, age, rownum as rn from customer order by age) where rn between :m and :n
MySql
select * from customer order by age limit :m, :n - :m
MS SQL

I don't know how to do it with MS sql server yet. I don't have ms sql server installed. If you happen to know it, please post your solution in the comment.

No comments:

Post a Comment