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 | >, >=, <, <=, <> | |
2 | IN | WHERE id IN (1, 2, 3, 4, 5) |
3 | UDF (more) |
|
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.