This shows you the differences between two versions of the page.
dev:sql:statements:select:home [2010/07/02 03:07] tdo |
dev:sql:statements:select:home [2016/06/28 22:38] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | {{page>:top_add&nofooter&noeditbtn}} | ||
- | <html><div align="center"><span style="color:red">DRAFT</span></div></html> | ||
- | ====== Omnidex SQL Statement: SELECT ====== | ||
- | {{page>:sql_bar&nofooter&noeditbtn}} | ||
- | ===== Description ===== | ||
- | The Omnidex SQL Select statement is the primary statement used to query records on Omnidex enhanced data. | ||
- | Omnidex will automatically optimize the SELECT statement using Omnidex indexes. | ||
- | ===== Syntax ===== | ||
- | The concise syntax for the Omnidex SELECT statement is the following: | ||
- | |||
- | <code SQL> | ||
- | SELECT expression_list | ||
- | FROM data_source | ||
- | [ WHERE clause ] | ||
- | [ GROUP BY expression_list ] | ||
- | [ HAVING predicates ] | ||
- | [ ORDER BY expression_list ] | ||
- | [ ON [ CURSOR ] cursor_no ] | [ INSTANCE instance_no ] | ||
- | [ WITH options ] | ||
- | </code> | ||
- | ==== Expression_list syntax: ==== | ||
- | <code> | ||
- | expression_list | ||
- | [ < TOP (n) | ||
- | [ SKIP(n) | EVERY(n) | RANDOM (n [, seed] ) ] ] | ||
- | [ < DISTINCT column | ALL >] | ||
- | [ SAMPLE(‘control_break’ [, ’qualifier’]) ] | ||
- | [ UNION [ALL] | INTERSECT | EXCEPT ] | ||
- | [ * ] | [ table.]column [column_alias] [, table.column ... ] | ||
- | [ (subquery) ] | ||
- | [ aggregate_function( [table.]column ) ] | ||
- | [ $uniquekey | $odxid ] | ||
- | |||
- | </code> | ||
- | |||
- | ==== FROM Clause syntax: ==== | ||
- | <code> | ||
- | FROM [database.]table1 [ table_alias ] [, [database.]table2 [ table_alias ] [ $omnidex ] ] | ||
- | [[ < LEFT | RIGHT >][ OUTER ] ] | ||
- | [ JOIN [database.]table2 ] | ||
- | [ ON table1.linkfield = table2.linkfield ] | ||
- | [ <AND| OR> NOT] [database.]tableN.linkfield = [database.]tableN.linkfield ] | ||
- | </code> | ||
- | ==== WHERE Clause Syntax: ==== | ||
- | <code> | ||
- | WHERE [ criteria_list ] | ||
- | [ EXISTS (subquery) ] | ||
- | [ IN (subquery) ] | ||
- | </code> | ||
- | |||
- | ==== GROUP BY Clause Syntax: ==== | ||
- | <code> | ||
- | GROUP BY group_by_columns | ||
- | HAVING [ left_operand operator subquery ] | ||
- | [ left_operand IN (subquery) ] | ||
- | </code> | ||
- | ==== ORDER BY Clause Syntax: ==== | ||
- | <code> | ||
- | ORDER BY [column | column_position ] [, column | column_position ] | ||
- | </code> | ||
- | |||
- | ==== WITH Clause Syntax: ==== | ||
- | <code> | ||
- | WITH options | ||
- | </code> | ||
- | |||
- | ===== Discussion ===== | ||
- | ==== Expression_list ==== | ||
- | The expression_list can be one of the following: | ||
- | |||
- | | * | All columns for the named tables using a syntax of [/[ database. ] table. ]] * | | ||
- | | column | A column, optionally qualified by a table, optionally with an alias using a syntax of [/[database.]table.]column [/[AS] column_alias]] | | ||
- | | (subquery) | A nested subquery that returns a single select item. | | ||
- | | expression | A standard SQL or Omnidex-specific function | | ||
- | |||
- | ==== table_list table_spec [join_syntax ] ==== | ||
- | | ||
- | One of the following: | ||
- | | table | A table using a syntax of[database.]table. | | ||
- | | $OMNIDEX | A dummy table consisting of one row and one column. | | ||
- | | (subquery) | A nested subquery. | | ||
- | ==== FROM Clause ==== | ||
- | |||
- | ==== WHERE Clause ==== | ||
- | ==== GROUP BY Clause ==== | ||
- | ==== HAVING Clause ==== | ||
- | ==== ORDER BY Clause ==== | ||
- | |||
- | Order by column is in the format of [database.][table.]column or table_alias.column. | ||
- | |||
- | Column can also be an alias name of the column. | ||
- | |||
- | ==== WITH options ==== | ||
- | |||
- | === PRESERVE_CRITERIA === | ||
- | |||
- | === PRESERVE_CRITERIA_ORDER === | ||
- | |||
- | ===== Examples ===== | ||
- | ==== Select all columns from table ==== | ||
- | |||
- | > select * from mytable | ||
- | ==== Select with Omnidex criteria on Quicktext column ==== | ||
- | |||
- | > select company, contact from mytable where company = 'Information'; | ||
- | |||
- | {{page>:bottom_add&nofooter&noeditbtn}} |