We use TOP command and ORDER_BY to implement paging for our application with Sybase database: select TOP 100 id, name from tableA order by id The problem is when add join tables, we start to receive duplicate "id" and hence the total record is less than expected (because one row on the main table can match many rows in child table). Anybody has a solution for this?
My query:
select TOP 100
a.id,
a.name,
b.name,
c.name
from tableA a
left outer join tableB b on
a.id =
b.id
left outer join tableC c on
a.id =
c.id
where
a.id < pass_in_id order by
a.id desc