Create auto numered column in mysql query

Discussion in 'MySQL' started by sameeraa4ever, Apr 25, 2010.

  1. #1
    Create auto numered column in mysql query

    select @rownum:=@rownum+1 nowef,
    p.* from item p, (SELECT @rownum:=0) r
    order by item_code
    desc limit 10;
     
    sameeraa4ever, Apr 25, 2010 IP
  2. NemoPlus

    NemoPlus Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hello,
    I'm not entirely sure what you are asking, but if you're looking for a solution to automatically number every row in a MySQL table, than the most easy solution would be to use the AUTO_INCREMENT attribute.
     
    NemoPlus, Apr 26, 2010 IP
  3. bibinsmk

    bibinsmk Active Member

    Messages:
    205
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    He is try to create numbered column in the select statement
     
    bibinsmk, Apr 26, 2010 IP
  4. Rajan Shah

    Rajan Shah Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    you can choose number and select column and make for it a query and giving primary key to it.
     
    Rajan Shah, May 4, 2010 IP
  5. starx

    starx Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    agree NemoPlus
     
    starx, May 4, 2010 IP
  6. crashus

    crashus Active Member

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #6
    Like 2nd post - add 'id' field and set it to auto_increment
     
    crashus, May 6, 2010 IP