Skip to content

SELECT Statement

OneAndonlyFinbar edited this page Feb 19, 2022 · 9 revisions

The SELECT command can be used to select rows aspects of a table.

Syntax

SELECT
[ALL | COLUMN | AGGREGATE_FUNCTION]
[AS alias]
[FROM table]
[WHERE condition(s)]

Examples

Selecting all rows

SELECT * FROM users

Select single column

SELECT money FROM users

Selecting maximum value in money column

SELECT MAX(money) FROM users

Selecting maximum value in money column WHERE user is above level 10

SELECT MAX(money) FROM users WHERE level > 10

Aliasing column userId to id

SELECT userId AS id FROM users WHERE userId = 5

Aliasing maximum userId column to `highestUserId

SELECT MAX(userId) AS highestUserId FROM users

Clone this wiki locally