Web Analytics Made Easy -
StatCounter simple question (order by) - CodingForum

Announcement

Collapse
No announcement yet.

simple question (order by)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • simple question (order by)

    How do i make the following:

    Code:
    $get_name = mysql_query("SELECT `id`, `name`, `link`, `value`, `description` from `offers` WHERE `countries` like '%us%' LIMIT 0, 25");
    How do i make that sort by ID from largest number to smallest number? idk where to put the order by
    Last edited by markman641; Aug 19, 2011, 04:50 PM.
    Ever want to see inside of a rave? Check out RedRoll and join our community of EDM lovers and rave fanatics.

  • #2
    ORDER BY is always the *last* thing other than LIMIT. (Well, except for some esoteric options you are not likely to ever need.)

    To sort from low to high, you use ORDER BY fieldname ASC
    To sort from high to low, you use ORDER BY fieldname DESC

    Except that ASC is optional, and is the default if DESC is not coded.

    Here, read the docs:
    http://dev.mysql.com/doc/refman/5.5/en/select.html
    Be yourself. No one else is as qualified.

    Comment


    • #3
      SELECT
      FROM
      WHERE
      GROUP BY
      HAVING
      LIMIT

      as a quick reminder of the syntax order (for most uses)

      Comment


      • #4
        Ummm...and ORDER BY?

        SELECT
        FROM
        WHERE
        GROUP BY
        HAVING
        ORDER BY
        LIMIT
        Be yourself. No one else is as qualified.

        Comment


        • #5
          Well yeah i should have included that but you had specifically told the OP where Order By clause went OP.

          Comment

          Working...
          X