SQLPathLab
Basic Query · Basic

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

Table:orders
orders
nameamount
Alice 1200
Bob 900
Cindy 1500
David 700

Run result

result
nameamount
Alice 1200
Bob 900
Cindy 1500
David 700

Common issues

Does SELECT always need FROM?

Usually yes when querying table data, but MySQL can also select expressions directly, such as SELECT 1 + 1.

Why avoid SELECT * in regular queries?

SELECT * returns every column, which can make results unclear and increase transfer and reading cost as tables grow.

Can SELECT contain calculated expressions?

Yes. For example, amount * 1.13 AS amount_with_tax. Use a clear alias for readability.

Tags

CommonFiltering

Was this explanation clear?