I've got the following working query:
string sqlString =
"SELECT * " +
"FROM (SELECT ROW_NUMBER() OVER (ORDER BY Id DESC) AS RowNum, * " +
"FROM StreamView " +
"WHERE Recipient = @Recipient " +
") AS RowConstrainedResult " +
"WHERE RowNum >= @startAt " +
"AND RowNum < @howMany " +
"ORDER BY RowNum;";
Which then returns the proper rows given a startAt and howMany variables. I would like to do the same with the query below:
string sqlString =
"SELECT DISTINCT l.* FROM Streams l " +
"INNER JOIN Friendships f ON f.Sender = @UserName OR f.Recipient = @UserName " +
"WHERE l.Sender <> @UserName AND l.Recipient <> @UserName AND ( " +
"l.Sender = f.Recipient OR l.Sender = f.Sender OR " +
"l.Recipient = f.Sender OR l.Recipient = f.Recipient) " +
"ORDER BY DateTime DESC;";
The query above works perfectly, but i'd like to get ranges instead of all the available rows. I need the same functionality of the first query.
Ideas? thanks.
getstream(0,10,'someone')) - This returns rows 0 to 10 from the table. I'm trying to do the same with the second query keeping its results as they already are now but adding range functionality (used with lazy scrolling)