Comparison Operators
| Operator | Description | Example |
|---|---|---|
= | Equal | WHERE age = 25 |
!= | Not equal | WHERE status != "inactive" |
> | Greater than | WHERE age > 21 |
>= | Greater than or equal | WHERE age >= 18 |
< | Less than | WHERE price < 100 |
<= | Less than or equal | WHERE quantity <= 10 |
Examples
Logical Operators
| Operator | Description | Example |
|---|---|---|
AND | Both conditions true | WHERE age > 21 AND active = true |
OR | Either condition true | WHERE role = "admin" OR role = "mod" |
NOT | Negate condition | WHERE NOT status = "banned" |
Examples
Precedence
NOT > AND > OR
Use parentheses to control order:
Arithmetic Operators
| Operator | Description | Example |
|---|---|---|
+ | Addition | price + tax |
- | Subtraction | total - discount |
* | Multiplication | quantity * price |
/ | Division | total / count |
% | Modulo | id % 2 |
Examples
Range Operators
BETWEEN
| Database | Output |
|---|---|
| PostgreSQL | SELECT * FROM users WHERE age BETWEEN 18 AND 65 |
| MySQL | SELECT * FROM users WHERE age BETWEEN 18 AND 65 |
| MongoDB | db.users.find({ age: { $gte: 18, $lte: 65 } }) |
NOT BETWEEN
Set Operators
IN
| Database | Output |
|---|---|
| PostgreSQL | SELECT * FROM users WHERE role IN ('admin', 'moderator', 'editor') |
| MySQL | SELECT * FROM users WHERE role IN ('admin', 'moderator', 'editor') |
| MongoDB | db.users.find({ role: { $in: ['admin', 'moderator', 'editor'] } }) |
NOT IN
| Database | Output |
|---|---|
| PostgreSQL | SELECT * FROM users WHERE status NOT IN ('banned', 'suspended') |
| MongoDB | db.users.find({ status: { $nin: ['banned', 'suspended'] } }) |
Pattern Operators
LIKE
| Pattern | Meaning |
|---|---|
% | Any sequence of characters |
_ | Any single character |
| Database | Output |
|---|---|
| PostgreSQL | SELECT * FROM users WHERE name LIKE 'John%' |
| MySQL | SELECT * FROM users WHERE name LIKE 'John%' |
| MongoDB | db.users.find({ name: { $regex: '^John' } }) |
NOT LIKE
ILIKE (Case Insensitive)
| Database | Output |
|---|---|
| PostgreSQL | SELECT * FROM users WHERE name ILIKE 'john%' |
| MySQL | SELECT * FROM users WHERE LOWER(name) LIKE 'john%' |
NULL Operators
IS NULL
| Database | Output |
|---|---|
| PostgreSQL | SELECT * FROM users WHERE deleted_at IS NULL |
| MySQL | SELECT * FROM users WHERE deleted_at IS NULL |
| MongoDB | db.users.find({ deleted_at: null }) |
IS NOT NULL
| Database | Output |
|---|---|
| PostgreSQL | SELECT * FROM users WHERE phone IS NOT NULL |
| MongoDB | db.users.find({ phone: { $ne: null } }) |
Operator Summary by Database
| Operator | PostgreSQL | MySQL | MongoDB |
|---|---|---|---|
= | = | = | $eq |
!= | != | != | $ne |
> | > | > | $gt |
>= | >= | >= | $gte |
< | < | < | $lt |
<= | <= | <= | $lte |
IN | IN | IN | $in |
NOT IN | NOT IN | NOT IN | $nin |
BETWEEN | BETWEEN | BETWEEN | $gte/$lte |
LIKE | LIKE | LIKE | $regex |
ILIKE | ILIKE | LIKE | $regex with i flag |
IS NULL | IS NULL | IS NULL | null |
IS NOT NULL | IS NOT NULL | IS NOT NULL | $ne: null |
AND | AND | AND | implicit |
OR | OR | OR | $or |
NOT | NOT | NOT | $not |
Limitations
Not currently supported in OmniQL (use native SQL):- JSON operators (
->,->>,@>,?) - Array operators (
ANY,ALL) - String concatenation (
||) - EXISTS / NOT EXISTS subqueries

