Skip to content

Commit

Permalink
Added ILIKE and REGEX examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
Serdaro committed Sep 17, 2015
1 parent f22766d commit 2eee28b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/QuerySQL.md
Expand Up @@ -16,18 +16,23 @@ Set<Employee> employees = map.values( new SqlPredicate( "active AND age < 30" )
- `active AND age>30`
- `active=false OR age = 45 OR name = 'Joe' `
- `active AND ( age > 20 OR salary < 60000 ) `
<br><br>

**Equality:** `=, !=, <, <=, >, >=`

- `<expression> = value`
- `age <= 30`
- `name = "Joe"`
- `salary != 50000`
<br><br>


**BETWEEN: ** `<attribute> [NOT] BETWEEN <value1> AND <value2>`

- `age BETWEEN 20 AND 33 ( same as age >= 20 AND age <= 33 )`
- `age NOT BETWEEN 30 AND 40 ( same as age < 30 OR age > 40 )`
<br><br>


**LIKE:** `<attribute> [NOT] LIKE 'expression'`

Expand All @@ -37,12 +42,29 @@ The `%` (percentage sign) is placeholder for multiple characters, an `_` (unders
- `name LIKE 'Jo_'` (true for 'Joe'; false for 'Josh')
- `name NOT LIKE 'Jo_'` (true for 'Josh'; false for 'Joe')
- `name LIKE 'J_s%'` (true for 'Josh', 'Joseph'; false 'John', 'Joe')
<br><br>


**IN:** `<attribute> [NOT] IN (val1, val2,...)`

- `age IN ( 20, 30, 40 )`
- `age NOT IN ( 60, 70 )`
- `active AND ( salary >= 50000 OR ( age NOT BETWEEN 20 AND 30 ) )`
- `age IN ( 20, 30, 40 ) AND salary BETWEEN ( 50000, 80000 )`
<br><br>



**ILIKE:** `<attribute> [NOT] ILIKE ‘expression’ `

Similar to LIKE predicate but in a case-insensitive manner.

- `name ILIKE 'Jo%'` (true for 'Joe', 'joe', 'jOe','Josh','joSH', etc.)
- `name ILIKE 'Jo_'` (true for 'Joe' or 'jOE'; false for 'Josh')
<br><br>



**REGEX**: `<attribute> [NOT] REGEX ‘expression’`

- `name REGEX 'abc-.*’` (true for 'abc-123'; false for 'abx-123')

0 comments on commit 2eee28b

Please sign in to comment.