Any SQL gurus here?

Discussion in 'Programming' started by nejcpass, Jul 25, 2007.

  1. #1
    I have a small problema and I hope someone can help me out a little bit!

    I nead to have a query limited to the first 1000 results. If the maximum is hit, a message will appear below the count stating: ‘* The maximum output was reached.

    Does this do "SELECT TOP 1000"?

    Thanks for your help!
     
    nejcpass, Jul 25, 2007 IP
  2. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The easiest way of doing it would be to limit it to 1001 records, only show the first 1000 and have an if statement on if the record count is 1001 then display your message.
     
    AstarothSolutions, Jul 25, 2007 IP
  3. nejcpass

    nejcpass Peon

    Messages:
    183
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for your help
     
    nejcpass, Jul 25, 2007 IP
  4. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #4
    No problem, I personally am not any form of SQL guru but "how can i do this" type questions are normally logic questions as much as programming/ syntax etc
     
    AstarothSolutions, Jul 25, 2007 IP
  5. ProgrammersTalk

    ProgrammersTalk Peon

    Messages:
    684
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    select * from table limit 1,1000;

    try that
     
    ProgrammersTalk, Jul 25, 2007 IP
  6. nejcpass

    nejcpass Peon

    Messages:
    183
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks everybody
     
    nejcpass, Jul 31, 2007 IP
  7. Tarkan

    Tarkan Peon

    Messages:
    491
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #7
    SELECT your_fields FROM table WHERE your_conditions ORDER BY your_order LIMIT 0,999

    That's the first 1000.
     
    Tarkan, Aug 1, 2007 IP
  8. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #8
    For MySQL it is

    For MS SQL then the original poster was correct with the TOP 1000 statement
     
    AstarothSolutions, Aug 2, 2007 IP