Understanding SQL SELECT Statement

ViaByte.Net

Sorting Data with ORDER BY

The ORDER BY clause is used to sort the result set based on one or more columns. For instance:

SELECT * FROM employees ORDER BY last_name ASC;

This query will retrieve all columns from the “employees” table and sort the result set in ascending order based on the “last_name” column.

Limiting the Result Set with LIMIT

The LIMIT clause is used to restrict the number of rows returned by a query. Here’s an example:

Bagikan:

Tinggalkan komentar