Where Clause Examples:
1)WHERE column_name operator value
Query shows use of "=" operator for matching data.
Displaying all the data where Country is "Germany".
1. |
WHERE Country='Germany' ; |
2. |
WHERE Fieldname=[UIPartname]; (Fetching the value from the UIPart as Input from the user) |
2)WHERE Condition1 AND/OR Condition2
Multiple conditions can be used with the help of "AND" and "OR" operator.
Displaying All the data where Country is Germany and Cities are 'Berlin' and 'Munchen'.
1. |
WHERE Country='Germany' AND (City='Berlin' OR City='München'); |
2. |
WHERE Fieldname1=[UIPartname1] AND (Fieldname2=[UIPartname2] OR Fieldname2=[UIPartname2]); (Fetching the value from UIParts as Input from the user) |
3)WHERE column_name LIKE pattern
Matching patterns from the data.
Displaying All the data having the pattern "land" e.g "Ireland" , "Auckland" etc.
1. |
WHERE Country LIKE %land%; |
2. |
WHERE Fieldname LIKE %[UIPartname]%; (Fetching the value from the UIPart as Input from the user) |
4)WHERE column_name IN (value1,value2,...)
Matching values from list of values.
Displaying all the data where city is in the List of values provided e.g "Paris" or "London".
1. |
WHERE City IN ('Paris','London'); |
2. |
WHERE Fieldname IN ([UIPartname1],[UIPartname2]); (Fetching the value from the UIPart as Input from the user) |
5)WHERE column_name BETWEEN value1 AND value2
Matching data from the Range of values.
Displaying all the data where Price lies within "10" and "20".
1. |
WHERE Price BETWEEN 10 AND 20; |
2. |
WHERE Fieldname BETWEEN [UIPartname1] AND [UIPartname2]; (Fetching the value from the UIPart as Input from the user) |
6)WHERE LOWER(data) LIKE LOWER('%inputvalue%')
Use of LOWER operator to convert the Text to Lowercase.
1. |
WHERE LOWER(Fieldname) like LOWER(%[UIPartname]%); (Fetching the value from the UIPart as Input from the user) |
Similarly Other SQLite 3's Where Clauses can be formed according to the Business requirements.
7)In where clause variables can be used on both sides. Matching data of two UIParts.
1. |
WHERE [UIPartname]=[UIPartname]; (Fetching the value from two UIParts as Input from the user) |
Note: Above Variables([]) options can be used for Local and RemoteDB in Select Operation and Update Operation as well.