PHP MySQL Order By,phpmysqlorderby_PHP教程

WBOY
Release: 2016-07-12 08:51:21
Original
821 people have browsed it

PHP MySQL Order By,phpmysqlorderby

ORDER BY 关键词用于对记录集中的数据进行排序。

ORDER BY 关键词

ORDER BY 关键词用于对记录集中的数据进行排序。

ORDER BY 关键词默认对记录进行升序排序。

如果你想降序排序,请使用 DESC 关键字。

语法

SELECT column_name(s)
FROM table_name
ORDER BY column_name(s) ASC|DESC
Copy after login

实例

下面的实例选取 "Persons" 表中存储的所有数据,并根据 "Age" 列对结果进行排序:

";
}

mysqli_close($con);
?>
Copy after login

以上结果将输出:

Glenn Quagmire 33
Peter Griffin 35
Copy after login

根据两列进行排序

可以根据多个列进行排序。当按照多个列进行排序时,只有第一列的值相同时才使用第二列:

SELECT column_name(s)
FROM table_name
ORDER BY column1, column2
Copy after login

 

相关阅读:

php 编程笔记分享 - 非常实用

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1130668.htmlTechArticlePHP MySQL Order By,phpmysqlorderby ORDER BY 关键词用于对记录集中的数据进行排序。 ORDER BY 关键词 ORDER BY 关键词用于对记录集中的数据进行排序。...
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 [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!