View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
AA2e72E AA2e72E is offline
external usenet poster
 
Posts: 400
Default SQL query syntax

You can only match anything beginning with 'An' or ending with 'An' in a
single SQL statement, thus:

SELECT ... FROM ... WHERE (Name = 'John' or Name like 'An%') and Age=26;

or

SELECT ... FROM ... WHERE (Name = 'John' or Name like '%An') and Age=26;

If you want anything that has An in it, try:

SELECT ... FROM ... WHERE (Name = 'John' or 0< INSTR(Name,'An') and Age=26;

The latter will work with the Text and Excel drivers: INSTR is not
universally supported.


In case you have not tweakedit yet, all SQL statements should end with
semi-colon (but some drivers are not fussy).