SQL WHERE: Difference between revisions
Jump to navigation
Jump to search
Line 8: | Line 8: | ||
<syntaxhighlight lang='sql'> | <syntaxhighlight lang='sql'> | ||
SELECT * FROM person WHERE person.name = 'Alice'; | SELECT * FROM person WHERE person.name = 'Alice' AND (person.eye_color = 'blue' OR person.eye_color = 'black'); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 22:06, 23 May 2024
Internal
Overview
The WHERE
clause is the mechanism for filtering out unwanted data from the result set. The WHERE
clause can be used with SELECT
, UPDATE
and DELETE
, but not with INSERT
.
SELECT * FROM person WHERE person.name = 'Alice' AND (person.eye_color = 'blue' OR person.eye_color = 'black');
The WHERE
clause may contain an arbitrary number of filter conditions separated by AND
, OR
and NOT
operators, and optionally grouped together with parentheses.
FROM <filter_condition> AND|OR <filter_condition> ...
Filter Conditions
NULL in Conditions
Also see: