Querying Data

One of the main purposes of a database is to have a repository or a data storage system where information can be extracted quickly. The SQL statement used to extract information from tables in a database is the SELECT statement.

The SELECT Statement

The SELECT statement is used to extract information from the database or, in other words, to ask questions (or queries) to the database.

The clauses or elements of the SELECT statement are FROM, WHERE, ORDER BY, GROUP BY, HAVING, TOP, and INTO. The only element that is always required for queries is the FROM clause, which is used to specify the table or view from which to extract information.

The basic syntax of SELECT is

SELECT column_list
FROM Table_name

When you issue a SELECT

Get Microsoft® SQL Server™ 2000 Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.