Recordset paging

Posted on 2005-05-17
Last Modified: 2010-03-19

I've got a set of data, like so:

UserID  |  SongID  |  Title  |  Name
700  |  4843  |  Turn The Music Up (Sample Only)  |  John Smith 1
10020  |  58834  |  The Way  |  John Smith 3
10466  |  58972  |  against the wall  |  John Smith 5
10466  |  58975  |  settle down new  |  John Smith 5
10466  |  58973  |  senyourita  |  John Smith 5
10466  |  58976  |  too late  |  John Smith 5
745  |  4409  |  Aida (Sarah McLachlan)  |  John Smith 2
10199  |  59243  |  Hustla'-featuring Venumb  |  John Smith 4

Normally when i want to do some recordset paging, i will pass into the stored procedure the page number, and the number of records per page, and then with the use of a temp table i can return the rows i need. The problem i have with the above scenario is that when i say i want 4 records, i actually want 4 UNIQUE UserID's, but as many records as are necessarry that are related to those 4 userID's.....does that make sense.....anyone have any idea how this can be achieved???

Thanks in advance

Question by:higgsy
    LVL 15

    Accepted Solution

    Hi higgsy,

    Does this do something like what you want?  you don't specifiy which four userid's you want to match...

    SELECT UserID, SongID, Title, [Name]
    FROM YourTable
    LVL 8

    Expert Comment

    SELECT UserID, SongID, Title, Name
    FROM YourTable
    WHERE USERID IN (10020,10466,745,10199 )

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
    Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
    Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
    Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now