DOCUMENT:Q143249 11-FEB-2000 [foxpro] TITLE :PRB: ORDER BY Field in Result Set Without Being in Field List PRODUCT :Microsoft FoxPro PROD/VER:WINDOWS:3.0,3.0b OPER/SYS: KEYWORDS: ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b ------------------------------------------------------------------------------- SYMPTOMS ======== When using the ORDER BY clause of a SQL SELECT statement, you must include the the ORDER BY field in the field list. If the ORDER BY field is not included in the field list, it is added by FoxPro without an error. STATUS ====== This behavior is by design. It is clearly documented in the Language Reference and help file that the ORDER BY field must be in the field list. The following quote is from the help file under the SELECT SQL topic: ORDER BY sorts query results based on data in one or more columns. Each Order_Item must correspond to a column in the query results MORE INFORMATION ================ Steps to Reproduce Behavior --------------------------- Enter the following command in the Command Window: SELECT last_name FROM samples/data/employee ORDER BY emp_id Notice that both last_name and emp_id are in the cursor even though the last_name field was the only field in the field list. Additional query words: VFoxWin ====================================================================== Keywords : Technology : kbVFPsearch kbAudDeveloper kbVFP300 kbVFP300b Version : WINDOWS:3.0,3.0b ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 2000.