PRB: "SQL Expression Too Complex" with Long IN Clause

Last reviewed: June 27, 1995
Article ID: Q103031
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5 and 2.5a
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, and 2.5a

SYMPTOMS

The "SQL expression too complex" error message appears if you have used 25 or more values in the IN clause of the SQL SELECT command.

CAUSE

The maximum number of values you may include in the IN clause is 24.

RESOLUTION

See below for an example of the problem and a workaround.

MORE INFORMATION

Steps to Reproduce Problem

  1. Use the CUSTOMER.DBF database in the TUTORIAL directory.

  2. Issue the following SQL SELECT command:

    Select * from customer where cno in; ('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15',;

       '16','17','18','19','20','21','22','23','24','25')
    
    
The "SQL expression too complex" error message appears.

Workaround

  1. Create a temporary database with one field in it called CNO.

  2. Issue the following SQL SELECT command:

          Select * from customer where cno in (select cno from temp)
    


Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a
KBCategory: kbprg kbprb
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: June 27, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.