1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need small help regarding SELECT next id in MySQL

Discussion in 'MySQL' started by Cyber Criminal, Jul 3, 2010.

  1. #1
    Hi Folks,

    I want to select next id from the table. I am getting this error

    can anyone please fix this code.

    $result = $dbase->get_results("SELECT * FROM `likes` WHERE like_id > $iLikeId ORDER BY like_id ASC LIMIT 1,1");
    Code (markup):
     
    Cyber Criminal, Jul 3, 2010 IP
  2. megamoose

    megamoose Well-Known Member

    Messages:
    71
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    105
    #2
    What type of field is like_id. Is it definitely an INT, because if not you will need to put $iLikeId in quotes.
     
    megamoose, Jul 3, 2010 IP
  3. Cyber Criminal

    Cyber Criminal Well-Known Member

    Messages:
    104
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    121
    #3
    Thanks for quick reply....

    Is this correct?
    $result4 = $dbase->get_results("SELECT * FROM `likes` WHERE like_id > '$iLikeId' ORDER BY like_id ASC LIMIT 1,1");
    Code (markup):
    Now that error has been fixed...but this code is to get id=2 because of ASC LIMIT 1,1.
    If I keep ASC LIMIT 2,1 it is getting id=3 always. ASC LIMIT 3,1 gets id=4.

    I need a code to get next id? not the same id everytime :( Did you understand my problem? :(
     
    Cyber Criminal, Jul 3, 2010 IP
  4. Cyber Criminal

    Cyber Criminal Well-Known Member

    Messages:
    104
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    121
    #4
    Problem has been solved

    Thanks to
    http://www.scottklarr.com/topic/111/how-to-select-previousnext-rows-in-mysql/
    Code (markup):
     
    Cyber Criminal, Jul 4, 2010 IP