SELECT
Selects the columns or expressions returned by a query.
Overview
SELECT defines the columns or expressions returned by a query. Listing only the required columns keeps the result shape stable and avoids unnecessary data transfer; calculated expressions should use clear aliases. Use SELECT * only when every column is genuinely needed.
Basic syntax
SELECT name, amount FROM orders;
Examples
SELECT example
Read only name and amount from orders and compare the returned columns with the SELECT list.
Sample table
orders| name | amount |
|---|---|
| Alice | 1200 |
| Bob | 900 |
| Cindy | 1500 |
| David | 700 |
Run result
| name | amount |
|---|---|
| Alice | 1200 |
| Bob | 900 |
| Cindy | 1500 |
| David | 700 |
Common issues
Usually yes when querying table data, but MySQL can also select expressions directly, such as SELECT 1 + 1.
SELECT * returns every column, which can make results unclear and increase transfer and reading cost as tables grow.
Yes. For example, amount * 1.13 AS amount_with_tax. Use a clear alias for readability.
Tags
Was this explanation clear?
Thanks. This feedback will inform the next content review.