Querying Data
The first (and possibly most immediately useful) operation that SQL allows you to perform on data is to select and return rows of data from tables stored within the database. This activity forms the core of exactly what a database represents, a large repository of searchable information.
All SQL queries, no matter how simple or complex, use the
SELECT
keyword
to specify the columns to fetch, the tables to fetch them from, and
any conditions that must be met for the rows to be retrieved.
SELECT falls into the group of commands known as
Data Manipulation Language
, or
DML, commands.
The full syntax for SELECT can be intimidating to
the new user, primarily because it sports a multitude of different
ways in which the query can be customized. For example, you might
wish to return only unique data rows, group certain rows together, or
even specify how the returned rows should be sorted.
For the moment, we’ll just look at the simplest cases.
In our example, we’ve tended to use capital letters for SQL commands and other reserved words, and lowercase letters for database object names (tables, columns, etc.). In most databases, the SQL commands are not case-sensitive, but the actual database object names may or may not be.