Codefixer - ASP tutorials, resources and software
asp.netPRO “Best ASP.NET Host” – DiscountASP.NET
Home   Articles   Resources   ASP directory   ASP Tutorials   Code Snippets   ASP Applications   Forum
Tuesday 13 May
MembersPro PayPal - ASP Membership software

asp.netPRO “Best ASP.NET Host” – DiscountASP.NET


ASP Partner ASP Partner ASP Partner more partners...

SQL explained: What is SQL | Select Statement | Select Where | Insert | Update/Edit | Delete | Order By | Select Between

SQL ORDER BY

The ORDER BY clause allows you to sort the retrieved records.

Syntax: SELECT * FROM TableName ORDER BY FieldName ASC/DESC

The ASC keyword selects the results in ascending order. Ascending order is the default and the ASC keyword can be left out. The DESC keyword returns the results in descending order.

If we wanted to select all the records in our database table below in Diagram1 and sort them in alphabetical order based on the FirstName field we could use the SQL statement below.

SELECT * FROM Members_tbl ORDER BY FirstName

Diagram 1
Order By

The first record retrieved would be the row with Dave Jones would lives in 32 Donki Park in Belfast as Dave comes alphabetically before Henry and Michael.

To return the rows in reverse alphabetical order based on the FirstName field we could use the SQL statement below.

SELECT * FROM Members_tbl ORDER BY FirstName DESC





ASP.NET 3.5/2.0 Web Hosting: 3 Months FREE – Click Here!




About | Contact | Advertise | Feedback | Hire Us | Link

Site developed by Michael Wall - Web Design Belfast N.Ireland.
Copyright © 2000-2008. All rights reserved.

Do you intend to move to ASP.NET or have you already?
Yes will do
Have done
ASP does fine
Not a priority


Directory Software