SQL
  SELECT Statement
  Operators
  Aggregate Functions
  Arthmetic Functions
  String Functions
  ORDER BY
  GROUP BY
  HAVING
  Joins
  INSERT Statement
  UPDATE Statement
  DELETE Statement


  Example Database:
   [Access Version]
   [MySQL Version]

SQL SELECT Statement

Definition: is used to select a row or rows of data from a table or tables that meet the set of criteria that you provide.

Syntax:
SELECT [DISTINCT] <attribute list>

FROM <table name> <alias>
WHERE <condition>

Explanation:
[DISTINCT] Used to return only distinct records.
<attribute list> This can be a * if returning all the database fields or a list of fields you wish to have returned. You can also have functions in your <attribute list>.
<table name> The name of the table or tables to be used in the SELECT.
<alias> Instead of using the full name of the table in the SELECT you can rename it as a short <alias> to simplify the SELECT.
<condition> This is the criteria which is used the determine which records are returned from the database.

Examples:
SELECT *
FROM accounts
This SELECT statement would return everything from the table Account
s

SELECT account_id, firstname, lastname
FROM accounts

This SELECT statement would return every record from the table Accounts, but only for the fields given.

SELECT account_id, addrline1,addrline2, city, prov, postalcode
FROM accounts
WHERE firstname = 'Mark'
AND lastname = 'McCulligh'

This SELECT statement would return the Account plus address for a person for every person with the first name Mark and last name Smith.

SELECT a.account_id, a.firstname, a.lastname, t.amount
FROM accounts a, transactions t
WHERE a.account_id = t.Account_id
AND firstname = 'Mark'
AND lastname = 'McCulligh'

This SELECT statement use the table alias to simplify the SELECT.

©Copyright VisualTech Components. All Rights Reserved.