All Products
Search
Document Center

OpenSearch:WHERE

Last Updated:Oct 19, 2026

Description

The WHERE clause is used to select data from a table based on specified conditions.

Syntax

select:
  SELECT [ DISTINCT ]
    { * | projectItem [, projectItem ]* }
  FROM tableExpression
    [ WHERE booleanExpression ]

booleanExpression can be one of the following types:

No.

Expression type

Example

0

AND, OR

  1. WHERE a > 1 AND a < 100

  2. WHERE a > 5 OR c > 100

1

>, >=, <, <=, <>

2

IN

WHERE id IN (1, 2, 3, 4, 5)

3

UDF (more)

  1. WHERE MATCHINDEX(brand, "Huawei")

  2. WHERE QUERY(brand, "Huawei OR OPPO")

  3. WHERE UDF(brand, "test") > 10

Examples

SELECT * FROM table WHERE f1 > 10 AND f2 < 5

SELECT * FROM table WHERE id IN (5, 6, 7, 8, 9)

Hint

SQL supports using Ha3 inverted index optimization in the WHERE clause to accelerate lookups. Examples include MATCHINDEX and QUERY, which implement syntax compatible with Ha3 queries, as well as equality conditions such as SELECT * FROM table WHERE f1 = 10. If f1 has an inverted index, the equality condition is automatically optimized into an inverted index lookup.