MariaDB Selecting Data
Select Statement in details
Setup
Set up the table and data first before running the following query.
1 | CREATE TABLE customer( |
LIMIT
Use the LIMIT clause to restrict the number of returned rows.
When you provide an offset m with a limit n, the first m rows will be ignored, and the following n rows will be returned.
syntax
1 | LIMIT offset, row_count |
example
1 | SELECT * FROM customer LIMIT 2; |
ORDER BY
Use the ORDER BY clause to order a resultset, such as that are returned from a SELECT statement.
1 | SELECT * FROM customer ORDER BY email; |
GROUP BY
use GROUP BY
clause in a SELECT statement to group rows together that have the same value in one or more column.
Example:
1 | SELECT city, count(*), avg(activeDays) from customer GROUP BY city; |