![]() ![]() ' value and return the total in the Tally field. ' Count the number of records with a PostalCode This example counts the number of records that have an entry in the PostalCode field and names the returned field Tally. ' Call EnumFields to print the contents of the Set rst = dbs.OpenRecordset("SELECT LastName, " _ ' Select the last name and first name values of all ' Modify this line to include the path to Northwind It calls the EnumFields procedure, which prints the contents of a Recordset object to the Debug window. This example creates a dynaset-type Recordset based on an SQL statement that selects the LastName and FirstName fields of all records in the Employees table. Note that this field does not actually exist in the Northwind database Employees table. Some of the following examples assume the existence of a hypothetical Salary field in an Employees table. ![]() UtterAccess is the premier Microsoft Access wiki and help forum. Links provided by the UtterAccess community. For more information, see the Help topic for the clause you are using. You can use the other clauses in a SELECT statement to further restrict and organize your returned data. The following example uses the title HeadCount to name the returned Field object in the resulting Recordset object: SELECT COUNT(EmployeeID) Whenever you use aggregate functions or queries that return ambiguous or duplicate Field object names, you must use the AS clause to provide an alternate name for the Field object. The following example uses the title Birth to name the returned Field object in the resulting Recordset object: SELECT BirthDate If you want a different field name or a name is not implied by the expression used to generate the field, use the AS reserved word. When a Recordset object is created, the Microsoft Jet database engine uses the table's field name as the Field object name in the Recordset object. WHERE Employees.Department = Supervisors.Department The SQL statement selects departments from the Employees table and supervisor names from the Supervisors table: SELECT Employees.Department, Supervisors.SupvName In the following example, the Department field is in both the Employees table and the Supervisors table. If a field name is included in more than one table in the FROM clause, precede it with the table name and the. The following example selects all of the fields in the Employees table. You can use an asterisk (*) to select all fields in a table. The minimum syntax for a SELECT statement is: Most SQL statements are either SELECT or SELECT…INTO statements. SELECT is usually the first word in an SQL statement. SELECT statements do not change data in the database. To perform this operation, the Microsoft Jet database engine searches the specified table or tables, extracts the chosen columns, selects rows that meet the criterion, and sorts or groups the resulting rows into the order specified. The name of the database containing the tables in tableexpression if they are not in the current database. The name of the table or tables containing the data you want to retrieve. The names to use as column headers instead of the original column names in table. If you include more than one field, they are retrieved in the order listed. ![]() The names of the fields containing the data you want to retrieve. The name of the table containing the fields from which records are selected. Specifies that all fields from the specified table or tables are selected. If none is specified, the default is ALL. Use the predicate to restrict the number of records returned. One of the following predicates: ALL, DISTINCT, DISTINCTROW, or TOP. The SELECT statement has these parts: Part ![]() Instructs the Microsoft Access database engine to return information from the database as a set of records. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |