====================================================================== Microsoft(R) Product Support Services Application Note (Text File) WX0639: QUERYING QUESTIONS & ANSWERS ====================================================================== Revision Date: 10/92 No Disk Included The following information applies to Microsoft Access(TM) version 1.0. -------------------------------------------------------------------- | INFORMATION PROVIDED IN THIS DOCUMENT AND ANY SOFTWARE THAT MAY | | ACCOMPANY THIS DOCUMENT (collectively referred to as an | | Application Note) IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY | | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO | | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A | | PARTICULAR PURPOSE. The user assumes the entire risk as to the | | accuracy and the use of this Application Note. This Application | | Note may be copied and distributed subject to the following | | conditions: 1) All text must be copied without modification and | | all pages must be included; 2) If software is included, all files | | on the disk(s) must be copied without modification [the MS-DOS(R) | | utility DISKCOPY is appropriate for this purpose]; 3) All | | components of this Application Note must be distributed together; | | and 4) This Application Note may not be distributed for profit. | | | | Copyright 1992 Microsoft Corporation. All Rights Reserved. | | Microsoft and MS-DOS are registered trademarks and Microsoft | | Access and Windows are trademarks of Microsoft Corporation. | | Btrieve is a registered trademark of SoftCraft, Inc., a Novell | | Company. dBASE III PLUS and dBASE IV are registered trademarks | | of Ashton-Tate Corporation. Paradox is a registered trademark of | | Ansa Software, a Borland company. | -------------------------------------------------------------------- 1. Q. How can I export the result of a query? A. To export the results of a query, you must create a table that contains the results. To do this, create a make-table query in Design view (choose Make Table from the Query menu). The resultant table will contain the data to be exported. After the make-table query is complete, choose Export from the File menu to export the data in the desired format. For more information, please refer to Chapter 4 of the "User's Guide." 2. Q. Can I join tables from different databases into one query? A. Yes, you can join tables from different databases into one query. Using the Attach Table method, you can generate queries from any supported data source (for example, Btrieve[R], dBASE III PLUS[R], dBASE IV[R], or Paradox[R]). 3. Q. Is data in tables stored in a sorted order? How can I view my data in sorted order? A. Data in tables is not stored in sorted order. Data is stored in the order in which it was entered. To view data in sorted order, create either a query or a form based on a query that uses the Sort field on the query grid. By default, if the table includes a primary key, the Datasheet view of the table will display the data sorted by the primary key. To view the data sorted by something other than the primary key alone, use a query, as previously described. 4. Q. How can I create computed columns in tables? A. Within the query, create a column that is defined as an expression. In general, it is helpful to think of queries as virtual tables; you can use a query wherever you can use a table. If you're familiar with SQL terminology, this is very similar to creating a view. Unlike most implementations of views, however, Microsoft Access views can be updated even if they involve joins from different data sources, such as Paradox, Btrieve, or separate Microsoft Access data sources. 5. Q. What is the difference between the keywords DISTINCT and DISTINCTROW? A. DISTINCT is part of the SQL standard and causes a query to return unique data, rather than unique records. For example, even if there are 10 customers named Jones, the query "SELECT DISTINCT Name FROM Customer" returns only one row containing Jones. In Microsoft Access queries, you specify DISTINCT by choosing Query Properties from the View menu and selecting the Unique Values Only check box. DISTINCTROW is unique to Microsoft Access and is not part of the SQL standard. It causes a query to return unique records, rather than unique data values. For example, if there are 10 customers named Jones, the query "SELECT DISTINCTROW Name FROM Customer" returns all 10 rows containing Jones. The major reason for adding the DISTINCTROW keyword to Microsoft Access SQL is to support semi-joins that can be updated (for example, one-to-many joins in which the output columns all come from the one-side table). DISTINCTROW is specified by default in Microsoft Access queries and is ignored in queries where it has no effect.