Updated on 2024-03-07 GMT+08:00

Analysis Statements - SELECT

Specifies the field to be queried.

Using * to query all fields.

SELECT *
Table 1 Using * to query all fields

account_number

firstname

gender

city

balance

employer

state

lastname

age

1

Amber

M

Brogan

39225

Pyrami

IL

Duke

32

16

Hattie

M

Dante

5686

Netagy

TN

Bond

36

13

Nanette

F

Nogal

32838

Quility

VA

Bates

28

18

Dale

M

Orick

4180

null

MD

Adams

32

Querying a Specified Field

SELECT firstname, lastname
Table 2 Querying a Specified Field

firstname

lastname

Amber

Duke

Hattie

Bond

Nanette

Bates

Dale

Adams

Using AS to Define Field Aliases

SELECT account_number AS num
Table 3 Using AS to define field aliases

num

1

16

13

18

Using the DISTINCT Statement

SELECT DISTINCT age
Table 4 Using the DISTINCT statement

age

32

36

28

Using SQL Functions

For details about functions, see Functions.

SELECT LENGTH(firstname) as len, firstname
Table 5 Using SQL functions

len

firstname

4

Amber

6

Hattie

7

Nanette

4

Dale