What is the purpose of using DESC and ASC in MySQL queries?
When querying data from a MySQL database, using DESC and ASC helps specify the desired order in which the results should be displayed. DESC stands for descending order, which arranges the results from highest to lowest, while ASC stands for ascending order, which arranges the results from lowest to highest. This allows for better control over the presentation of data in the query results.
// Example MySQL query using DESC to display results in descending order
$sql = "SELECT * FROM table_name ORDER BY column_name DESC";
$result = mysqli_query($conn, $sql);
// Example MySQL query using ASC to display results in ascending order
$sql = "SELECT * FROM table_name ORDER BY column_name ASC";
$result = mysqli_query($conn, $sql);