Microsoft Office Tutorials and References
In Depth Information
<function> ::= Count |
Max |
Min |
<tableref> ::= <table> |
<table> <tablealias>
Where <alias> is an alternate name of a column, <tablealias> is an alternate name of a table
and, <expression> is a valid expression.
Note The Select statement is the most complicated statement in the SQL language.
Although the syntax in the preceding code might seem intimidating, keep in mind that it rep€
resents only a small part of the full syntax for a Select statement. However, the syntax listed
here is generally supported by all database vendors, so you can use it with most applications.
Simple Select Statements
Rather than spend a lot of time trying to learn the syntax rules for the Select statement,
you’re going to see a series of examples for common situations that illustrate how use the
Select statement.
Retrieving Everything
The following Select statement retrieves all the columns and rows from the Customers table:
Select *
From Customers
The asterisk (*) indicates that all the columns in the table should be retrieved, and the From
clause indicates that the command should pull the records from the Customers table.
Retrieving a List of Columns
Suppose that you don’t want to retrieve all the columns from a table. You can use this Select
statement to retrieve only the columns that you are planning to use. This query retrieves only
the CustomerId and Name columns from the Customers table.
Select CustomerId, Name
From Customers
Tip Only Take What You Really Need
Although using an * to retrieve columns makes your SQL statement easier to type, it can
cause problems. The more data you retrieve from a database, the longer the query will take
to process and the more additional memory will be required to hold the results. Granted,
the extra time and space might be negligible for many queries, but it’s still a good program€
ming practice to request only the resources you really need.
Search JabSto ::

Custom Search