I have the following code:
(SELECT id, slug
FROM anuncios
WHERE vum = '$idcategoria'
ORDER BY RAND())
ORDER BY publicado DESC
I need SQL to sort and at the same time randomize, except that the above code is just doing the sorting, randomization does not work.
Follow the example image:
The above image is what I'm trying to make work, notice that we have two first ads have the field (advertising = 2) with banner, and the last three without banner have the field (advertising = 1). I need the first two that have the field (advertising = 2) to be the first to be displayed (but with each update of the page these two ads randomize). The ads that have the remaining field (publicity = 1) also randomize.