Getting Data from a Database

The SELECT statement is the most commonly used statement when you're using SQL. This is what enables you to retrieve data from a relational database. Listing 4.2 illustrates the basic structure of the SELECT statement.

Listing 4.2. The Basic Structure of a SELECT Statement
SELECT select_list
[ INTO new_table ]
FROM table_source
[ WHERE search_condition ]
[ GROUP BY group_by_expression ]
[ HAVING search_condition ]
[ ORDER BY order_expression [ ASC | DESC ] ]

In its simplest form, a SELECT statement begins with the word SELECT. SELECT is followed by one or more fields from the database table, each field separated by a comma. Then there's the FROM clause, which specifies the source of the data being queried. It ends ...

Get Programming Data-Driven Web Applications with ASP.NET 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.