Select Clause

The Select clause specifies what columns in the underlying table or tables you want to retrieve. To retrieve all records in a certain table, use:


To select particular columns in a table, such as txtLastName and txtFirstName, list each name separated by commas:

SELECT txtLastName, txtFirstName

Predicates can also be used as part of the Select statement to further restrict what records get returned. For example, you can use the Distinct predicate to limit the results to unique records:


The Top predicate allows you to restrict the number of records returned to a certain number or percent. For example, the following statement limits the number of records to be returned to five:

SELECT TOP 5 intSalesAmt from tblOrders

0 0

Post a comment