WEB WTF SQL ERROR v. LIMIT 1.

Discussion in 'OT Technology' started by brds, Jul 9, 2008.

  1. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,652
    Likes Received:
    15
    Location:
    Atlanta
    Trying to run the following query:

    Code:
    [COLOR=black][FONT=verdana][COLOR=black][FONT=verdana]SELECT userID FROM TICKETS_USERS ORDER BY userID DESC LIMIT 1;[/FONT][/COLOR][/FONT][/COLOR]
    But i'm getting the error:

    If i take out the 'LIMIT 1', it works just fine. WTF is SQL's version of MySQL's 'LIMIT' function?
     
  2. Frequency

    Frequency New Member

    Joined:
    Dec 30, 2004
    Messages:
    7,504
    Likes Received:
    0
    Location:
    PA
    Code:
    [COLOR=black][FONT=verdana][COLOR=black][FONT=verdana]SELECT [B]TOP 1 [/B]userID FROM TICKETS_USERS ORDER BY userID DESC;[/FONT][/COLOR][/FONT][/COLOR]
    
     
  3. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    What SQL engine are you using? MSSql Server? Access? MySQL? Oracle? Postgres? SQLLite?
     
  4. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,652
    Likes Received:
    15
    Location:
    Atlanta
    Thanks
     
  5. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,652
    Likes Received:
    15
    Location:
    Atlanta
    Here's another SQL question... what's the command to purge a table so that when a new entry is made, the auto incrementing PK starts at 1 again?
     
  6. 2ofdem

    2ofdem OT Supporter

    Joined:
    Jun 17, 2003
    Messages:
    114,854
    Likes Received:
    8
    Location:
    aus.vic.mel
    ALTER TABLE table_goes_here AUTO_INCREMENT = 1

    or

    TRUNCATE TABLE (table_goes_here);

    both will work truncate will drop all the info in the table too.
     
  7. Frequency

    Frequency New Member

    Joined:
    Dec 30, 2004
    Messages:
    7,504
    Likes Received:
    0
    Location:
    PA
  8. noon

    noon get high and teach me how to listen

    Joined:
    May 4, 2002
    Messages:
    3,384
    Likes Received:
    0
    Location:
    Lawrence, KS
    try LIMIT 0,1
     
  9. Mr J

    Mr J New Member

    Joined:
    Jun 4, 2004
    Messages:
    55,061
    Likes Received:
    1
    Location:
    England
    DROP TABLE TABLENAME
     
  10. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,652
    Likes Received:
    15
    Location:
    Atlanta
    That would just remove the table... truncate is what i was looking for i just couldn't remember what it was called.... thanks though.
     
  11. ge0

    ge0 New Member

    Joined:
    Oct 31, 2005
    Messages:
    8,398
    Likes Received:
    0
    Location:
    JERSEY

    You don't like Ruby on rails?
     

Share This Page