Retrieving data
The command for retrieving or reading data from our database is called SELECT
. Of all the SQL commands, this is the one which we will probably use most often. The syntax is rather complex, or can be, if we choose to use all the various options. However, the basic syntax is quite simple and is as follows:
SELECT <what> FROM <table_name> [WHERE <where-conditions>] [ORDER BY <column_name>];
In the <what>
part, we specify the columns that we want to retrieve data from. The WHERE
and ORDER BY
lines are how we filter and sort our data, respectively.
Note
Complete documentation of the SELECT
command, refer to the following location:
Retrieving everything
A common <what>
condition is to specify every column. This is done using an asterisk (*
). For example, to retrieve everything from our employees
table, we could do the following:
SELECT * FROM employees;
Because we have not specified a WHERE
clause, everything...