While the title is broad, then my question is simple. I have a table, lets call it “news”, where are articles. Normally articles are being pulled by order, but on the frontpage they are being displayed only if they are “featured”. However, if the query is:
SELECT * FROM {TABLE_PREFIX}news WHERE `status` = '1' AND `featured` = '1' ORDER BY `order` LIMIT 0, 4
Then at least some articles must be featured.. However, what if there are only 2 featured articles? So I would like to have a fallback, so when there are only 2 featured articles, it would also get two non-featured.
I thought that, this would do the trick, but it doesn’t work like I planned it:
SELECT * FROM {TABLE_PREFIX}news WHERE `status` = '1' AND `featured` = '1' ORDER BY `featured`, `order` LIMIT 0, 4
You are on the right track, but you still select on
featured = 1. Try this: