Page 1 of 1
ORDER BY multiple factors?
Posted: Thu Dec 04, 2008 4:46 am
by Sindarin
I am trying to order results by 2 values, article_importance and article_publish_date,
Using,
ORDER BY article_importance ASC AND article_publish_date ASC
generates a syntax error. Any help?
Re: ORDER BY multiple factors?
Posted: Thu Dec 04, 2008 4:48 am
by mintedjo
I think its a comma instead of AND
Code: Select all
ORDER BY article_importance ASC, article_publish_date ASC
If thats not right then try it without a comma
Code: Select all
ORDER BY article_importance ASC article_publish_date ASC
Re: ORDER BY multiple factors?
Posted: Thu Dec 04, 2008 4:58 am
by pbs
Also try
ORDER BY article_importance, article_publish_date ASC
Re: ORDER BY multiple factors?
Posted: Thu Dec 04, 2008 5:15 am
by mintedjo
pbs wrote:
Code: Select all
ORDER BY article_importance, article_publish_date ASC
Doesn't account for the situation where you need to order one thing asc and another desc

Re: ORDER BY multiple factors?
Posted: Thu Dec 04, 2008 7:17 am
by Chris Corbyn
mintedjo wrote:pbs wrote:
Code: Select all
ORDER BY article_importance, article_publish_date ASC
Doesn't account for the situation where you need to order one thing asc and another desc

Code: Select all
ORDER BY article_importance ASC, article_publish_date DESC
Re: ORDER BY multiple factors?
Posted: Fri Dec 05, 2008 4:28 am
by mintedjo
Chris Corbyn wrote:mintedjo wrote:pbs wrote:
Code: Select all
ORDER BY article_importance, article_publish_date ASC
Doesn't account for the situation where you need to order one thing asc and another desc

Code: Select all
ORDER BY article_importance ASC, article_publish_date DESC
I already posted that exact code above, only using 2 ascendings because... well thats what the question was about
