Home > Database > Mysql Tutorial > Comprehensive exposure to SQL syntax (3)

Comprehensive exposure to SQL syntax (3)

黄舟
Release: 2016-12-24 17:45:42
Original
1110 people have browsed it

ORDER BY conditional statement

This conditional clause is usually used in conjunction with the SELECT statement to sort the query results according to the specified field.


SELECT fieldlist


FROM table


WHERE selectcriteria


ORDER BY field[ASC|DESC][,field2 [ASC|DESC][,...]]


 fieldlist

 The name of the field to be queried. Which can be used with ALL, DISTINCT, DISINCTROW, or TOP.


table


The name of the table to be queried.


 selectcriteria


 Query standard settings.


 field1

Specify which field to use as the basis for sorting. If you do not add ORDER BY, the data set queried will not be sorted.

 ASC

 Ascending order categories. (Default)


DESC

Categories in descending order.

For example:

Or if we want to arrange the output data according to the order of birth, we can use the following command.


 SELECT Name, Birthday

 FROM Staff Form


 ORDER BY Birthday

 SELECT LastName,FirstName

 FROM Employees

 ORDER BY LastName ASC;

 IN Conditional Clause

 Specify which table of the external database to be selected. (Must be a database that the Microsoft Jet database engine can connect to, such as dBase, Paradox, etc.)

 
SELECT|INSERT]INTO destination IN
{path|["path" "type"]| [""[type;DATABASE=path]]}
FROM tableexPRession IN
{path|["path" "type"]|[""[type;DATABASE=path]]}
destination


The name of the external table into which data is to be inserted.

 tableexpression

 Table name or the name of the table from which data is read. This parameter can be a single table name, or a stored SQL query, etc.

path

Contains the full path name of the table.

Type

The type name of the database, usually used when the database belongs to Jet database. (For example: dBASE III, dBASE IV, Paradox 3.x, Paradox 4.x, or Btrieve)

For example: the following two paragraphs have the same meaning


PartA... .FROM Table
IN ""[dBASE IV;DATABASE=C:DBASEDATASALES;];

PartB....FROM Table
IN "C:DBASEDATASALES" "dBASE IV;"



 For example: Microsoft Jet database


SELECT customer number
FROM customer form
IN CUSTOMER.MDB
WHERE customer number Like "A*";
Where CUSTOMER.MDBO is the database name of Jet database, which contains the customer table.

For example: dBASE III or IV
SELECT customer number
FROM customer form
IN "C:DBASEDATASALES" "dBASE IV;"
WHERE customer number Like "A*";
So when we use a database different from access, we must specify the type name of the database.

The above is the content of comprehensive contact with SQL syntax (3). For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template