Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: SQL Server
Expertise: Beginner
Aug 10, 1999



A Simple Sort Not Working

I have the following:
sql="select * from products"
How do I sort or order by two columns retrieved in the "*"?

You need to specify them directly in a clause following the one you have, as in:

select * from authors
order by au_lname,au_fname
This will get you all the columns in authors sorted by last name, then first name.

Note that it is poor practice to use "select *" because you could be opening a Pandora's box of unexpected results. It is better practice to name the columns you expect in the result set or use the INFORMATION_SCHEMA views to find out what you need.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date