Causes of Common SELECT - SQL Error Messages

Last reviewed: April 30, 1996
Article ID: Q109580
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, and 2.5b
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a, and 2.5b
  • Microsoft FoxPro for Macintosh, version 2.5b

SUMMARY

The following error messages can be produced by improper usage of the SELECT statement:

     SQL column <field> not found
     <field> is not a memory variable
     Alias <alias> not found

The code sample below illustrates some possible causes of these error messages and explains why they occur.

MORE INFORMATION

The following code sample executes a variety of SELECT statements. If the SELECT statement produces a error message, the reasoning behind the error message is explained.

   CREATE TABLE customer (company C(20),state C(2))
   INSERT INTO customer (company,state) VALUES ;
    ("ABC Company","WA")
   INSERT INTO customer (company,state) VALUES ;
    ("Main Street Store ","NY")

   CLOSE ALL

   USE customer ALIAS test

   SELECT customer.company FROM test WHERE customer.state = "WA"

    * Produces Error: SQL column 'COMPANY' not found
    * customer.company does not exist. The table is aliased as 'test'.
    * This should be: "test.company"
    * customer.state does not exist. The table is aliased as 'test'.
    * "customer.state" should be "test.state"

   SELECT customer.company FROM test WHERE test.state = "WA"

    * Produces Error: SQL column 'COMPANY' not found
    * customer.company does not exist. The table is aliased as 'test'.
    * "customer.company" should be "test.company"

   SELECT test.company FROM test WHERE customer.state = "WA"

    * Produces Error: 'STATE' is not a memory variable
    * customer.state does not exist. The table is aliased as 'test'.
    * "customer.state" should be "test.state"

   SELECT test.company FROM test WHERE test.state = "WA"

    * OK.  This is a valid SELECT statement.

   SELECT customer.company FROM customer WHERE customer.state = "WA"

    * Produces Error: SQL column 'COMPANY' not found
    * Since the customer table is already open, FoxPro will try
    * to use it. It won't go to disk to open the table. But
    * the table is aliased as 'test' so the fields should be
    * aliased as 'test'.
    * customer.company does not exist. The table is aliased as 'test'.
    * "customer.company" should be "test.company"

   SELECT customer.company FROM customer WHERE test.state = "WA"

    * Produces Error: SQL column 'COMPANY' not found
    * Since the customer table is already open, Fox will try
    * to use it. It won't go to disk to open the table. But
    * the table is aliased as 'test' so the fields should be
    * aliased as 'test'.
    * customer.company does not exist. The table is aliased as 'test'.
    * "customer.company" should be "test.company"

   SELECT test.company FROM customer WHERE customer.state = "WA"

    * Produces Error: 'STATE' is not a memory variable
    * Since the customer table is already open, FoxPro will try
    * to use it. It won't go to disk to open the table. But
    * the table is aliased as 'test' so the fields should be
    * aliased as 'test'.
    * customer.state does not exist. The table is aliased as 'test'.
    * "customer.state" should be "test.state"

   SELECT test.company FROM customer WHERE test.state = "WA"

    * OK. This is a valid SELECT statement.

   CLOSE ALL

   USE customer ALIAS customer

   SELECT customer.company FROM customer WHERE customer.state = "WA"

    * OK. This is a valid SELECT statement.

   SELECT customer.company FROM customer WHERE test.state = "WA"

    * Produces Error: Alias 'TEST' not found
    * There is no table named test.
    * No table is opened with a alias of test.
    * "test.state" should be "customer.state"

   SELECT test.company FROM customer WHERE customer.state = "WA"

    * Produces Error: SQL column 'COMPANY' not found
    * There is no table named test.
    * No table is opened with a alias of test.
    * "test.company" should be "customer.company"

   SELECT test.company FROM customer WHERE test.state = "WA"

    * Produces Error: SQL column 'COMPANY' not found
    * There is no table named test.
    * No table is opened with a alias of test.
    * "test.company" should be "customer.company"

   CLOSE ALL

   SELECT customer.company FROM customer WHERE customer.state = "WA"

    * OK.  This is a valid SELECT statement.

   SELECT customer.company FROM customer WHERE test.state = "WA"

    * Produces Error: Alias 'TEST' not found
    * There is no table named test.
    * No table is opened with a alias of test.
    * "test.state" should be "customer.state"

   SELECT test.company FROM customer WHERE customer.state = "WA"

    * Produces Error: SQL column 'COMPANY' not found
    * There is no table named test.
    * No table is opened with a alias of test.
    * "test.company" should be "customer.company"

   SELECT test.company FROM customer WHERE test.state = "WA"

    * Produces Error: SQL column 'COMPANY' not found
    * There is no table named test.
    * No table is opened with a alias of test.
    * "test.company" should be "customer.company"


Additional reference words: VFoxWin 3.00 FoxMac FoxDos FoxWin 2.00 2.50
2.50a 2.50b
errmsg err
msg
KBCategory: kbprg kberrmsg kbref
KBSubcategory: FxprgSql


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.

Last reviewed: April 30, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.