Sunday, 2024-04-28
Stay Close
Site menu
Catalog categories
Computers [3]
Business [3]
Travel [3]
Technology [3]
Sports [3]
Health [3]
Arts [3]
Home & Garden [3]
Entertainment [3]
Tag Board
Our poll
Rate my site
Total of answers: 82
Main » Articles » Computers

How to Sort a MySQL Query Using ORDER
by rows of a MySQL SELECT query are displayed in an arbitrary order or unpredictable. Since the return is more inside and hash algorithms that search for what you do with your data, the order of the rows is generally not useful to a developer. To return the rows of an order, you can use the ORDER BY clause of the SELECT to sort the base .

Form SELECT to return the rows in which you are interested. At this point, the order in which rows are returned is not of importance. This example queries a customer database for a list of customers with negative balances. Example: SELECT * FROM customers WHERE balance <0.0 ;

Add an ORDER BY clause. ORDER BY, MySQL will tell the server to sort the rows by a column. For example, if you want to see all outstanding accounts to balance, you can add "ORDER BY balance" at the end of the consultation. Example: SELECT * FROM customers WHERE balance <0.0 ORDER BY balance ;

Define in which direction to sort, as the order of the rows returned may not yet be meaningful. You can return the rows in ascending or descending order .

use ASC or DESC. Using the ASC order for you to see the smallest number first. DESC using the data type for you to see the largest number first. In this consultation, which seeks customers with the highest negative balance in the first place. ORDER BY return the array with the largest negative number (the smallest) at the top. Example: SELECT * FROM customers WHERE balance <0.0 ORDER BY ASC balance ;

Sort by multiple columns, as sometimes you'll come across large groups of rows that were ordered in the same issue. For example, if there are 100 customers in its database with a balance of 0, users appear in arbitrary order. It is better to have at least two criteria to classify this type of situation .

Using multiple criteria classification separated by commas. Here, customers are shown in alphabetical order by name after they are sorted by the balance. Example: SELECT * FROM customers WHERE balance <0.0 balance ORDER BY name ASC

Category: Computers | Added by: hamza (2009-01-31)
Views: 573 | Rating: 0.0/0 |
Total comments: 0
Name *:
Email *:
Code *:
Login form
Search
Site friends
Download StayClose Toolbar

Download StayClose Toolbar

 



( )
Privacy
 
Copyright MyCorp © 2024