SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru dragonhawk's Avatar
    Join Date
    Apr 2002
    Location
    Melbourne
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Randomising rows in MySQL

    Just wondering if there is a way you can select an entire table in MySQL and instead of selecting from top to bottom, it randomises it?

    For example, if you do a select * from table, you may get

    row 1
    row 2
    row 3
    row 4
    etc...

    is there a way to select * from table and get randomised rows like so:

    row4
    row1
    row3
    row2
    etc...

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SELECT *
    FROM TableName
    ORDER BY RAND()


  3. #3
    SitePoint Guru dragonhawk's Avatar
    Join Date
    Apr 2002
    Location
    Melbourne
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perfect... thanks


Bookmarks

Posting Permissions

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