It is a query example how to select limited count of random values from a MySQL database table and make it in order:

SELECT * FROM
    (SELECT * FROM table_name ORDER BY RAND() LIMIT 3) as selected_rows
ORDER BY column_name DESC;

Where:
“table_name” is the name of the table where the values are selected,
“selected_rows” is the name of the rows of the table “table_name” are selected,
“column_name” is the name of the column by which the values are ordered.

Share

3 Comments on Select limited random values and order it

  1. wifi says:

    this is raw code.. i dont know how to put it in my blog
    can this put on plugin maybe?

  2. wifi, it is not just for blog, it is only a MySQL query to select limited random values and order it. I think if you know how to work with MySQL, you’ll know how to use this code.

    Thanks.

  3. wifi says:

    ooh.. ok, sorry for my mistake
    i tough it for WP purposes

Leave a Reply

Info