Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2002
    Posts
    5

    Question Unanswered: First row before the current row

    hi,

    I have a table (POST) :

    Post_id, Post_cat,Post_posterid,Post_post

    And there is a posterid (41), he have five post with Post_id 's : 1 20 34 60 -72

    I want to select the first Post_id (in this example 34) before the Post_id (60) where posterid = $posterid

    I tried :

    PHP Code:

    $query
    ="
        SELECT Post_id, Post_cat ,Post_post
        FROM POST
           WHERE Post_posterid = '$ Post_posterid '
           AND Post_id < 
    $Post_id
                    "

    but it gives the first Post_id.

  2. #2
    Join Date
    Apr 2003
    Location
    Rome, Italy
    Posts
    2
    $query="
    SELECT Post_id, Post_cat ,Post_post
    FROM POST
    WHERE Post_posterid = '$ Post_posterid '
    AND Post_id < $Post_id
    order by Post_id desc limit 1";

  3. #3
    Join Date
    Feb 2002
    Posts
    5
    thanks!

    it works ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •