Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2002
    Posts
    22

    Unanswered: mysql_query: order results by row

    Hi there;

    Got a little problem I can't work out.
    Want to select all the row's from my table, but order the results starting at a particular row [which is defined by a user]. i.e.

    Rows in table
    1
    2
    3
    4
    5
    6

    Want to select all rows but starting from row 5 giving me:
    5
    6
    1
    2
    3
    4

    Thanks in advance

  2. #2
    Join Date
    Sep 2002
    Location
    Montreal, Canada
    Posts
    224
    Provided Answers: 1

    Re: mysql_query: order results by row

    Originally posted by orange
    Hi there;

    Got a little problem I can't work out.
    Want to select all the row's from my table, but order the results starting at a particular row [which is defined by a user]. i.e.

    Rows in table
    1
    2
    3
    4
    5
    6

    Want to select all rows but starting from row 5 giving me:
    5
    6
    1
    2
    3
    4

    Thanks in advance
    SELECT columnName, IF(columnName >= start, columnName - start, columnName + start) as myorder
    FROM tableName
    ORDER BY myorder

    In your example, just replace start with 5 in the above query

    SELECT columnName, IF(columnName >= 5, columnName - 5, columnName + 5) as myorder
    FROM tableName
    ORDER BY myorder

    Hope this helps.

  3. #3
    Join Date
    Mar 2002
    Posts
    22
    Hi there,

    Thanks for the tip, have actually done a work around in PHP that works great for me!!

    Thanks any-way...

Posting Permissions

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