Conditional

complex

Like

 

Basics of the SELECT Statement

In a relational database, data is stored in tables. An example table would relate Inland Revenue Number, Name, and Address:

EmployeeAddressTable

IRD

FirstName

LastName

Address

City

Country

95001234

Fred

Spade 

40 Fort Street

Cambridge

New Zealand 

94001235

Jennifer

JustJeans 

45 Center Place

Cambridge

New Zealand 

93001236

Sandy

Shaws 

56 Christ Street

Hamilton

New Zealand 

92001237

Gwenyth

Moller 

24 Grey Street

Cambridge

United Kingdom 

If you want to see the address of each employee. Use the SELECT statement:

SELECT FirstName, LastName, Address, City, Country
FROM EmployeeAddressTable;

The following is the results of your query of the database:

First Name

Last Name

Address

City

Country

Fred

Spade 

40 Fort Street

Cambridge

New Zealand 

Jennifer

JustJeans 

45 Center Place

Cambridge

New Zealand 

Sandy

Shaws 

56 Christ Street

Hamilton

New Zealand 

Gwenyth

Moller 

24 Grey Street

Cambridge

United Kingdom 

Specifically, you asked for the columns called FirstName, LastName, Address, City, and Country. Note that column names and table names do not have spaces...following Reddicks naming conventions; and that the statement ends with a semicolon (;). The general form for a SELECT statement, retrieving all of the rows in the table is:

SELECT ColumnName, ColumnName, ...
FROM TableName;

To get all columns of a table without typing all column names, use:

SELECT * FROM TableName;

The star representing the common wildcard for everything! Unfortunately each database management system (DBMS) and database software has different methods for logging in to the database and entering SQL commands.

Local Menu
NLD - Home - New Zealand - Gallery - Links - Rugby World Cup - Site Map

home index file