B
B
bbaggins2017-05-09 14:33:19
MySQL
bbaggins, 2017-05-09 14:33:19

How to display materials in random order?

Friends, hello everyone!
Can you tell me how to randomize content? listing below:

$query->order($db->quoteName('a.featured') . ' DESC')->order($db->quoteName('a.publish_up') . ' DESC');

Answer the question

In order to leave comments, you need to log in

3 answer(s)
B
bbaggins, 2017-05-09
@bbaggins

It seems to work:

$query->order('a.featured DESC,' . $query->rand());

M
Max, 2017-05-09
@MaxDukov

Well, remove the sort. Will be in the order of entry in the table.

T
ThunderCat, 2017-05-09
@ThunderCat

ORDER BY RAND(), this is not the fastest operation, but if the query will be executed frequently, it can be accelerated

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question