Monday, July 30, 2012

The SELECT Statement - Retrieval Queries

Retrieval queries are needed in order to get information from database. The SELECT statement is used for retrieving information from the databases.

SELECT  <attribute_list>
FROM    <table_list>
WHERE   <condition>


The attribute list is the attribute you want to select, the table list is the name of the table to be queried and the condition filters the information to be retrieved.

Example of simple SELECT query:












In this example, we only select 2 attributes from the table employee, without a condition.
When you add conditions to the select statement, this filters the information to be retrieved by the SELECT statement.
When we add the conditon "where sex='M'; are displayed.











Using of asterisk(*) for attributes will select all available attributes from the table.

 

Using aliases will modify the headings of the retrieved queries.

The statement to be added: as 'alias' 




No comments:

Post a Comment