SQL Help

Discussion in 'MySQL' started by cris02, Mar 12, 2006.

  1. #1
    just i would like to ask how can i detect the first record, and last record in mysql table? in msaccess it's simply movefirst or movelast how to do that in mysql.
    thanks
     
    cris02, Mar 12, 2006 IP
  2. Will.Spencer

    Will.Spencer NetBuilder

    Messages:
    14,789
    Likes Received:
    1,040
    Best Answers:
    0
    Trophy Points:
    375
    #2
    Could you use LIMIT 1 to get the first record?

    SELECT * FROM MyTable Where MyField > "" ORDER BY MyIndex
    LIMIT 1; 
    Code (markup):
    Could you use LIMIT 1 in combination with DESC to reverse the sort order and get the last record?

    SELECT * FROM MyTable ORDER BY MyIndex DESC LIMIT 1;
    Code (markup):
     
    Will.Spencer, Mar 12, 2006 IP
  3. cris02

    cris02 Member

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    hi thanks.. just want to ask what is myindex? is this the string that i want to look for?
     
    cris02, Mar 13, 2006 IP