Retrieving Records with the SELECT Clause

Retrieving Records with the SELECT Clause

The SELECT clause is at the core of every query that retrieves data. It tells the database engine which fields to return. A common form of the SELECT clause is

 SELECT *  

This clause means "return all the fields you find in the specified record source." This form of the command is handy because you don't need to know the names of fields to retrieve them from a table. Retrieving all the columns in a table can be inefficient, however, particularly when you need only two columns and your query retrieves two dozen.

So, in addition to telling the database engine to return all the fields in the record source, you also have the ability to specify exactly which fields you want to retrieve. This limiting effect can improve the efficiency of a query, particularly in large tables with many fields, because you're retrieving only the fields you need.

A SELECT clause that retrieves only the contents of the first and last names stored in a table looks like this:

 SELECT FirstName, LastName  

Note also that a SELECT clause isn't complete without a FROM clause (so the SELECT clauses shown in this section can't stand on their own). For more about the SELECT clause, see examples for the FROM clause in the next section.



Database Access with Visual Basic. NET
Database Access with Visual Basic .NET (3rd Edition)
ISBN: 0672323435
EAN: 2147483647
Year: 2003
Pages: 97

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net