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.