MySQL select records with changes in field

Discussion in 'MySQL' started by stewhall, Aug 28, 2008.

  1. #1
    I have a table that I need to select only the records where a field value is different to the value in the previous record.

    Example

    ID TestField
    1 0
    2 0
    3 1
    4 1
    5 2
    6 2
    7 1
    8 0

    Records 1,3,5,7,8 would be retrieved.

    Any help would be much appreciated
    Thanks
    Stew
     
    stewhall, Aug 28, 2008 IP
  2. CreativeClans

    CreativeClans Peon

    Messages:
    128
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Select all rows and loop through them with PHP (or whatever language you use).
     
    CreativeClans, Aug 29, 2008 IP