If you want XYZ to be first, then followed by A, B, and C then you'll need
to something more than a simple ORDER BY. I would use a CASE statement like
this:
select company_name
from company
order by CASE when company_id = #theId# then 0 ELSE 1 END, company_name
The case statement will return 0 if the company ids match and will return 1
for everyone else. That way the "everyone else" companies will sort by the
next field in the order by, which is their name.
You can see it working by putting the CASE statement in the SELECT clause
instead of in the ORDER BY. I find this to be a handy trick.
Mark
-----Original Message-----
From: Brad Roberts [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 13, 2003 12:09 PM
To: CF-Talk
Subject: Query Sorting
I've got an app where several companies share the same database...
When a user searches for products, XYZ Company wants their products to show
up first (on their website), followed by other brands. Is there a way to do
this with one query?
Thanks,
Brad
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4