In the previous sections, we have seen how to insert information into database
tables. A common use is to select data from the tables located in a database.
Immediately, we see two keywords: we need to SQL SELECT information FROM a table.
Note that a table is a container that resides in the database where the data is
stored. For more information about how the contains the data and from where this
data came form you need to review again the previous segments of SQL Tutorial.. Hence we
have the most basic SQL structure:
To illustrate the above example, assume that we have the following table:
Table: Employees
FirstName |
LastName |
Email |
DOB |
Phone |
Austin |
Hennery |
austin.it@gamail.com |
24/11/1978 |
446 102-2222 |
Creston |
Narvon |
narvon_crest@hotmail.com |
22/04/1976 |
443 325-4545 |
Kate |
Bladen |
kbladen@usa.net |
01/05/1980 |
326 503-3232 |
Angela |
Julie |
julieee@yahoo.co.uk |
11/12/1977 |
326 323-8888 |
Bobbi |
Ferguson |
bobi123@kiwibox.com |
10/02/1970 |
506 252-9875 |
Cute |
Alfa |
cafa@gmail.com |
19/05/1972 |
506 272-4566 |
We shall use this table as an example throughout the SQL Tutorial (this table
will appear in all lessons). To select all the employees in this table, we key in,
Result:
FirstName |
Austin |
Creston |
Kate |
Angela |
Bobbi |
Cute |
Multiple column names can be selected, as well as multiple table names with
SQL Select keyword.
To select the entire table of Employees we will use this query.
The result of the above SQL select statement will be as under
Rreult:
FirstName |
LastName |
Email |
DOB |
Phone |
Austin |
Hennery |
austin.it@gamail.com |
24/11/1978 |
446 102-2222 |
Creston |
Narvon |
narvon_crest@hotmail.com |
22/04/1976 |
443 325-4545 |
Kate |
Bladen |
kbladen@usa.net |
01/05/1980 |
326 503-3232 |
Angela |
Julie |
julieee@yahoo.co.uk |
11/12/1977 |
326 323-8888 |
Bobbi |
Ferguson |
bobi123@kiwibox.com |
10/02/1970 |
506 252-9875 |
Cute |
Alfa |
cafa@gmail.com |
19/05/1972 |
506 272-4566 |