Hi adrian,
Many thanks for your reply - really appreciate it. I like the suggestion about using PHP to use a different query depending on a variable. However, in this case I would like to just list all the entries in the table. So it's not what's displayed that's important, it's the order in which they are displayed.
Your database display table is interesting, and I'm not quite sure I understand it. Could you explain what it means, and how you worked it out? Also, any advanced info you have on how the ORDER BY works would be great. The Manual only really mentions it briefly.
To get back to my problem, I worked out why the sticky wasn't sorting by date_from as I expected - well, it was, I just had a 2002 instead of a 2003 and hadn't noticed. Ahem, sorry. So it would seem that:
SELECT id_news, date_from, sticky, active
FROM pi_news
ORDER BY sticky DESC , active DESC , date_from DESC
Does result in:
id_news date_from sticky active
2 2003-01-25 00:00:00 y y
1 2003-01-23 13:00:00 y y
4 2003-01-23 00:00:00 n y
5 2003-01-18 00:00:00 n y
3 2003-01-10 00:00:00 n y
6 2003-01-19 13:00:00 n n
Which is exactly what I wanted - sorted by sticky (which is then sorted by date_from), then sorted by active (which is then sorted by date_from).
So, I suppose I never really had a question that could be answered properly in the first place. Apologies 🙂
However, any info on ORDER BY (links, tutorials etc) would be greatly appreciated as I still don't understand how it works and am basically just using trial and error.
Many thanks,
Leon Chevalier