WHERE Expression [ AND | OR Expression ]*
For example:
WHERE name = 'Hello World'
true
to be generated if the value from the name accessor is equal to the value "Hello World".JoSQL supports the following "standard" SQL operators:
- =
- <=
- >=
- !=
- >
- <
- [ NOT ] IN [ LIKE ] [ ALL ]
- [ NOT ] BETWEEN
- IS [ NOT ] NULL
- [ NOT ] LIKE
- *
- -
- +
- /
- %
- AND
- OR
It is also possible to use non-Boolean operators to return a Boolean result, for example in JoSQL:
WHERE 10000 * 1
true
. JoSQL (like C) assumes that a non-zero result is true
, and zero is false
. Similarly non-NULL values evaluate to true
and NULL values evaluate to false
, for example:WHERE upper ('Hello World')
true
, but:WHERE upper (NULL)
false
.JoSQL uses lazy-evaluation when evaluating the WHERE clause (and the HAVING clause), and evaluates top-down, so it is generally better to put clauses that will limit the set of records "higher" up in the list. JoSQL supports grouping of clauses via brackets and the use of AND and OR to provide grouping. For example:
WHERE 1000 = 1000 AND ('a' != 'b' OR :x $= 'Hello World')
WHERE :x = NULL AND :x = 'null' AND :x IS NULL
= null
in Java and got sick of having to write IS NULL
in SQL!)Wherever possible JoSQL makes use of the Comparable interface, that is if 2 objects that need to be compared are Comparable then the
Comparable.compareTo(Object,Object)
method will be used. If they objects don't implement the Comparable interface then they are converted to strings and then compared. It should be noted that numbers are handled slightly differently because (for some reason!) sub-classes of Number are not comparable. In this way you can then perform custom comparisons on your objects.Save Values, Bind Variables (Normal and Special), Functions, Number constants, Accessors and the constants TRUE, FALSE and NULL can all be used (in conjunction with the operators listed above) in the formation of an Expression.
For the Save Values, it should be noted that only those that have been saved due to the EXECUTE ON ALL clause are available for use.