Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


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

A Simple Sort Not Working

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

Answer:
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.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date