March 26th, 2010

SELECT * (ALL Columns)

Posted by admin in C. SELECT Statement

An asterisk (*) is used after the SELECT to indicate that all columns are to be returned. This keeps you from having to specify all column names, so do not enter any column names when you use the * option. SELECT * should not be used in a host-language program, since extra columns may be added to the TABLE later, returning too many columns to the program. Host-language programs will be covered when we get to batch programming.

A simple SELECT statement format is:

SELECT [ALL | DISTINCT] [* | column1[, column2, ...]]
  FROM  table1[, table2, ...];

Remember that the [ | ] symbols are only to show choices and are not a part of the finished statement.

> The asterisk (*) option is used to select all the columns in a table.
> The ALL option is used to select all values for a column, including duplicates.
> The DISTINCT option is used to suppress duplicate row values from being selected.
> The default between DISTINCT and ALL is ALL. Therefore, the ALL option never needs to be specified and is always implied, unless it is overridden by the DISTINCT option.

March 25th, 2010

SELECT Statement

Posted by admin in C. SELECT Statement

Download Video: MP4


Relational databases have their data stored and retrieved in two-dimensional tables. The SQL command to retrieve data is the SELECT statement. This statement will specify the columns to be returned and may specify the rows to be included. The columns and rows may come from one or more tables or views. The result of the SELECT statement is in the form of a table and is called the “Result Table.” Go on and we will cover the details.

 SELECT   [ALL | DISTINCT]
          [* | column1[, column2, ...]]
   FROM   [table1 correlation, ...
         | view1 correlation, ...]
 {WHERE    condition1[, condition2, ...]}
 {GROUP BY column1[, column2, ...]}
{HAVING    condition1[, condition2, ...]}
 {ORDER BY column1 [ASC | DESC][, column2 [ASC | DESC], ...]};

UPPER CASE characters Must be entered as shown
lower case characters   User specified variable
( )                             Parentheses must be entered where shown
|                               Denotes OR condition
[ ]                             Enclose required parameters, choose only 1
{ }                            Enclose optional parameters
Underline                   Default parameter

Note: || (double vertical bar) is a concatenation symbol and is entered into the statement as shown.

March 24th, 2010

Collating Sequence

Posted by admin in B. SQL Basics

The collating sequence is the sequence of the data if it is sorted in ascending or descending order. This is important if you are testing for a range of numbers (<, =, >).

PCs and PC-servers store characters in the ASCII format. Mainframe computers store characters in the EBCDIC format.

Regardless of how the data is stored internally, it is normally displayed graphically as a single character as shown under the EBCDIC or ASCII columns.

These characters can be converted to either a two-digit hexadecimal number (HEX 00-FF), or a three-digit decimal number (DEC 0-255) for further analysis and manipulation.

Note: SQL Server 2005 allows a collating sequence choice at time of installation.

Next Page »