All Products
Search
Document Center

OpenSearch:SELECT

Last Updated:Oct 10, 2024

SELECT statements are used to select data from tables. SELECT statements are the core of the query syntax. All advanced query syntax is used based on SELECT statements. This topic describes the simple syntax of SELECT statements supported by High-performance Search Edition. For information about how to use advanced syntax of SELECT statements, see other topics.

Syntax

SELECT:
  SELECT [ DISTINCT ]
  	{ * | projectItem [, projectItem ]* }
  FROM tableExpression
  	[ WHERE booleanExpression ]
  	[ GROUP BY { groupItem [, groupItem ]* } ]
    [ ORDER BY { orderByItem [, OrderByItem ]* }]
  	[ HAVING booleanExpression ]
    [ LIMIT number]
    [ OFFSET number]
  
projectItem:
  expression [ [ AS ] columnAlias ]
  | tableAlias . *

Example

SELECT * FROM table;

SELECT f1, f2 AS ff FROM table;

SELECT DISTINCT f FROM table;

SELECT * FROM (
      SELECT f1, count(*) AS num
      FROM t1
      GROUP BY f1
  ) tt
  WHERE tt.num > 100;