HOME | PHP Tutorial | CSS
facebook icon
AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP
PHP Tutorial

PHP forms
HTML Tutorial

CSS Tutorial

SQL mysql order by columns, by date, by asc, by desc, random with PHP


The SQL ORDER BY is used to sort the data in ascending or descending order from database, based on one or more columns.
The ORDER BY keyword sorts the records in ascending order by defaultin database. If you want to sort the records in descending order, use the DESC keyword.

SQL mysql order by columns asc or desc - example


Syntax: The basic syntax of the mysqli order by;
SELECT col1, col2, col3, ...
FROM name_table
ORDER BY col1, col2, col3,... ASC|DESC;


Example 1: Your database named as Customers
ID Name Contact Address City
1

Jones Cruise Ana Maria Will Str. 57 Paris
2 Robert Caine Ana Trujillo Avda. Larga 24 Roma
3 Brad Bale Antonio mauro Mataderos 19 Madrid

The following -SQL order by - select all - Name -from "Customers" table, sorted by the "City" column:
SELECT * FROM Name ORDER BY City;

The result
ID Name Contact Address City
3 Brad Bale Antonio mauro Mataderos 19 Madrid
1

Jones Cruise Ana Maria Will Str. 57 Paris
2 Robert Caine Ana Trujillo Avda. Larga 24 Roma
Note: The ORDER BY keyword sorts the records in ascending order by default

SQL ORDER BY DESC Example - How to create

The following SQL statement selects all Name from the "Customers" table, sorted DESCENDING by the "City" column:

Example 2: welcome.php
SELECT * FROM Name
ORDER BY City DESC;

The results -
ID Name Contact Address City
2 Robert Caine Ana Trujillo Avda. Larga 24 Roma
1

Jones Cruise Ana Maria Will Str. 57 Paris
3 Brad Bale Antonio mauro Mataderos 19 Madrid

mysql order by, mysql select query php, mysql order by 2 columns, by date, by multiple columns, by random, by asc, by desc SQL mysql order by columns, by date, by asc, by desc, random with PHP - sql tutorial

2819. SQL Tutorial
Gives you clear, concise and easy to understand SQL tutorial with practical examples. You will learn how to write SQL query like a Pro.
http://www.zentut.com/sql-tutorial/

3229. SQL tutorial will teach you how to use SQL - Database, sql tutorial
SQL tutorial will teach you how to use SQL - Database sql tutorial
https://www.agernic.com/sql-tutorial/sql-tutorials-sql-database.html

2560. Disclaimer - SQL Tutorial

http://www.sql-tutorial.net/disclaimer.asp

2569. SQL database table - SQL Tutorial

http://www.sql-tutorial.net/sql-database-table.asp

3290. SQL delete row - SQL delete table, sql tutorial
SQL delete row - SQL delete table sql tutorial
https://www.agernic.com/sql-tutorial/sql-delete-row-sql-delete-table.html

2817. PL/SQL Tutorial
We provide you with a comprehensive PL/SQL tutorial to help you learn PL/SQL quick and fun.
http://www.zentut.com/plsql-tutorial/

Your add here
PHP strtoupper() function

PHP str_split() function

PHP md5() function

PHP ltrim() function

PHP htmlentities() function

PHP strstr() function

PHP count() Function

PHP isset() Function

PHP html_entity_decode() function

PHP trim() function

PHP explode() function

PHP print() function

PHP printf() function

PHP implode() function

PHP ucwords() function

PHP lcfirst() function

SQL WHERE AND & OR multiple conditions
CSS Text Wrap
PHP Date / Time Functions - how to create? - example
CSS width and height - CSS Properties - Dimensions units
CSS text-align
HTML Colors