Results 1 to 2 of 2

Thread: Select latest 3 records ONLY

Hybrid View

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Location
    Sussex, England
    Posts
    45
    Anyone tell me the SQL query i need to use to do this ? I'm currently using :

    SELECT Title, ID FROM NewsArticles WHERE ID > ((SELECT MAX(ID) from NewsArticles)-3) ORDER BY ID DESC

    But if the ID fields are not consecutive for whatever reason it will select only 2 or even 1 record.

    I'm sure it's something really easy ... i think i'm having a bad day !

    Thanks in advance
    Ian.
    Ian Clarke BSc (Hons) - Web Applications Programmer
    Ricardo Consulting Engineers Ltd.
    Email : [email protected]

  2. #2
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    SELECT TOP 3 ID, Title FROM NewsArticles ORDER BY ID DESC

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width