diff --git a/guide/english/sql/sql-where-clause/index.md b/guide/english/sql/sql-where-clause/index.md index 69da235b7c..a6eee18e05 100644 --- a/guide/english/sql/sql-where-clause/index.md +++ b/guide/english/sql/sql-where-clause/index.md @@ -2,11 +2,11 @@ title: SQL Where Clause --- -## SQL Where Clause +# SQL Where Clause ### `WHERE` Clause (and/or, `IN`, `BETWEEN`, and `LIKE`) -The `WHERE` clause is used to filter the number of rows returned. +The `WHERE` clause is used to filter the number of rows returned, based on one or more conditions provided by user. In this case all five of these will be used is a some what ridiculous `WHERE` clause. @@ -33,12 +33,34 @@ select studentID, FullName, sat_score, rcd_updated from student; 9 rows in set (0.00 sec) ``` + We 'd like to apply the following filters: * `WHERE` Student IDs are between 1 and 5 (inclusive) * `OR` studentID = 8 -Here's an updated query, where any record that has an SAT score that's in this list (1000, 1400) will not be presented: +```sql + +select studentID, FullName, sat_score, recordUpdated +from student +where (studentID between 1 and 5 or studentID = 8); +``` + +```text ++-----------+----------------------+-----------+---------------------+ +| studentID | FullName | sat_score | rcd_updated | ++-----------+----------------------+-----------+---------------------+ +| 1 | Monique Davis | 400 | 2017-08-16 15:34:50 | +| 2 | Teri Gutierrez | 800 | 2017-08-16 15:34:50 | +| 3 | Spencer Pautier | 1000 | 2017-08-16 15:34:50 | +| 4 | Louis Ramsey | 1200 | 2017-08-16 15:34:50 | +| 5 | Alvin Greene | 1200 | 2017-08-16 15:34:50 | +| 8 | Donald D. Chamberlin | 2400 | 2017-08-16 15:35:33 | ++-----------+----------------------+-----------+---------------------+ +6 rows in set (0.00 sec) +``` + +Here's an updated query, where any record that has a SAT score that's in the list (1000, 1400) will not be presented in addition to the above conditions: ```sql