PROBLEM

SQL syntax for LIKE statement uses the characters: % and _

Last Published: April 25, 2020

Solution or Workaround

Question:

Getting syntax errors or a blank table when attempting wildcard character searches using the LIKE SQL statement.

Answer:

The LIKE statement needs to be used as part of the WHERE clause. Use the percent sign ( % ) for a global wildcard character and the underscore ( _ ) for a single character wildcard.

Example:

Consider a table called 'Categories' and a Field called 'CategoryID'. To find a particular record that contains, for example, the word 'seafood'. Use the following syntax in the SQL Connect dialog box:

Select: *
from: Categories
where: Categories.CategoryID like 'Sea%'

or

where: Categories.CategoryID like 'Seafoo_'

Notes:

Do not use the asterik ( * ) as the global wildcard character, the question mark ( ? ) as a single character wildcard, or the pound sign ( # ) as a single character wildcard. They do not give correct results in the LIKE statement.

Article ID:000001483

Software:
  • Legacy Products

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options