Difference between revisions of "SQL Syntax Considerations"

From AgileApps Support Wiki
imported>Aeric
(Created page with "__NOINDEX__ ;Considerations: :* SQL syntax is not case-sensitive, except for table names and field names. :* Backticks are (<tt>`</tt>) are needed around any table or field name …")
 
imported>Aeric
m (Text replace - '__NOINDEX__' to '<noinclude>__NOINDEX__</noinclude>')
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
__NOINDEX__
<noinclude>__NOINDEX__</noinclude>
;Considerations:
;Considerations:
:* SQL syntax is not case-sensitive, except for table names and field names.
:* SQL syntax is not case-sensitive, except for table names and field names.
Line 18: Line 18:
::which means that parser found a word it recognized, but didn't find other things it expected before it got to that word.
::which means that parser found a word it recognized, but didn't find other things it expected before it got to that word.
-->
-->
:* If you do a query on different tables that have fields with the same name, you should provide  column aliases for those fields. (Otherwise, a query for <tt>A.phone</tt> and <tt>B.phone</tt> identifies both sets of values as "phone". A column alias like <tt>A.phone AS A-phone</tt> makes it possible to tell which table a set of values came from.)
:: ''Learn more:'' [[SQL Syntax#column_expr|column_expr]]

Latest revision as of 00:17, 12 December 2012

Considerations
  • SQL syntax is not case-sensitive, except for table names and field names.
  • Backticks are (`) are needed around any table or field name that is one of the SQL Reserved Words.
For example: SELECT * FROM `Order`
Without the backticks, you get an error like this:
Encountered "Order" at line column 15. Was expecting one of (...
That error means the parser found a word it recognized, but didn't find other things it expected before it got to that word.
  • When either a table name or a field name is reserved word, and both are used together, then backticks are needed around the combination.
For example: `Order.order_number`
  • If you do a query on different tables that have fields with the same name, you should provide column aliases for those fields. (Otherwise, a query for A.phone and B.phone identifies both sets of values as "phone". A column alias like A.phone AS A-phone makes it possible to tell which table a set of values came from.)
Learn more: column_expr