Skip to content

SELECT Statement

OneAndonlyFinbar edited this page Jan 22, 2022 · 9 revisions

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

Syntax

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

Compatibility

Aggregate Functions

Name Description
MAX() Maximum value for column
MIN() Minimum value for column
SUM() Sum value for column
COUNT() Row count
STDEV() Column Standard Deviation
AVG() Column Average

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