I have query where i want to select featured ads with standard ads in ONE mysql query (one query because website is high traffic so doing two queries in the database will result in performance problems)
*The requirement is to select all the featured ads then select 2 standard ads AND they all must be ordered randomly. *
SO i used the following query, which works fine with the UNION keyword, but the problem is ordering of the RANDOM is only working for the second query.
( SELECT * FROM ads WHERE status='Y' AND priority='High' ORDER BY RAND() )
UNION (SELECT * FROM ads WHERE status='Y' AND count<=limits
AND priority!='High'
ORDER BY RAND() LIMIT 0 , 2
)
what i am i doing wrong here ? any ideas ? And As a side question any performance friendly ways to select random rows than using RAND keyword ?