<< Click to Display Table of Contents >> Navigation: Apollo SQL > Using Apollo SQL > Overview |
Apollo SQL provides built-in SQL query support for all Apollo products and technologies.
Apollo SQL supports a subset of the SQL-92 standard.
A common error in using SQL support is using reserved words in your SQL statements. Some common field names such as DESC, TO, FROM, KEY, MAX, PRIMARY, SUM, TIME, YEAR must be surrounded with "[" and "]" in order to reference them. More here.
Differences in Apollo SQL from TQuery (Apollo VCL)
•Compound evaluators must be enclosed in parenthesis as follows:
SELECT * FROM test WHERE (State = 'CA') and (AGE > 50)
•Date strings must be wrapped in single quotes as follows:
SELECT * FROM test WHERE hiredate = '7/1/2015'
Reserved words as field/column names and/or column names using spaces must be enclosed in square brackets as follows: [This Is a long Name] compared to TQuery's "This is a long name". These identifiers are used for field names as well as for table names.
Example:
SELECT a.first AS [First Name],
a.last AS [Last Name],
a.[date] AS [Date] FROM test a
WHERE (a.[date] >= #01/31/2015#)
ORDER BY a.[date] DESC
Comments embedded in Apollo SQL statements are allowed, and must be enclosed between "/*" and "*/". Example:
SELECT * FROM /* this is a comment */ test WHERE salary > 25000