Microsoft KB Archive/46020

{| = Using Apostrophes and Quotation Marks with SQL WHERE Clause =
 * width="100%"|

Last reviewed: October 31, 1994

Article ID: Q46020 The information in this article applies to:
 * Q+E for Microsoft Excel for Windows, version 2.1

SUMMARY
When using character constants in an SQL WHERE clause, you must use a set of apostrophes or quotation marks around the string constant. If one apostrophe or quotation mark occurs within the string, make sure there is a second, matching one at the point the first one occurs.

More Information:

If a file is named TEST.DBF and the data is in a field named SAMPLE, the following statement selects all of the entries with SQL:

SELECT SAMPLE FROM TEST.DBF The following statement selects those occurrences of the string that don't uses: SELECT SAMPLE FROM TEST.DBF WHERE SAMPLE='don''t' The following statement selects those occurrences of the string that &quot;false&quot; uses: SELECT SAMPLE FROM TEST.DBF WHERE SAMPLE=&quot;&quot;&quot;false&quot;&quot;&quot; Note: The inner set of quotation marks are part of the string and appear in the file. Make sure to use quotation marks if the string has quotation marks in or around it. The same rule applies to apostrophes.
 * }