AQL Logical and Comparison Operators
Operators are used in AQL statements to determine any equality or difference between values. By using operators in the WHERE clause of an AQL statement, the results are filtered by those results that match the conditions in the WHERE clause.
The following table lists the supported logical and comparison operators.
Operator |
Description |
Example |
---|---|---|
|
Multiplies two values and returns the result. |
SELECT * FROM flows WHERE sourceBytes * 1024 < 1 |
|
The equal to operator compares two values and returns true if they are equal. |
SELECT * FROM EVENTS WHERE sourceIP = destinationIP |
|
Compares two values and returns true if they are unequal. |
SELECT * FROM events WHERE sourceIP != destinationip |
|
Compares two values and returns true if the value on the left side is less than or equal to, the value on the right side. |
SELECT * FROM flows WHERE sourceBytes < 64 AND destinationBytes <= 64 |
|
Compares two values and returns true if the value on the left side is greater than or equal to the value on the right side. |
SELECT * FROM flows WHERE sourceBytes > 64 AND destinationBytes >= 64 |
|
Divides two values and returns the result. |
SELECT * FROM flows WHERE sourceBytes / 8 > 64 |
|
Adds two values and returns the result. |
SELECT * FROM flows WHERE sourceBytes + destinationBytes < 64 |
|
Subtracts one value from another and returns the result. |
SELECT * FROM flows WHERE sourceBytes - destinationBytes > 0 |
|
Takes a value and raises it to the specified power and returns the result. |
SELECT * FROM flows WHERE sourceBytes ^ 2 < 256 |
|
Takes the modulo of a value and returns the result. |
SELECT * FROM flows WHERE sourceBytes % 8 == 7 |
|
Takes the left side and right side of a statement and returns true if both are true. |
SELECT * FROM events WHERE (sourceIP = destinationIP) AND (sourcePort = destinationPort) |
|
Takes in a left side and two values and returns true if the left side is between the two values. |
SELECT * FROM events WHERE magnitude BETWEEN 1 AND 5 |
|
Parameter to order by that allows a BCP47 language tag to collate. |
SELECT * FROM EVENTS ORDER BY sourceIP DESC COLLATE 'de-CH' |
|
Creates a named cursor that contains results that can be queried at a different time. |
SELECT * FROM EVENTS INTO 'MyCursor' WHERE.... |
|
Takes in a statement and returns true if the statement evaluates as false. |
SELECT * FROM EVENTS WHERE NOT (sourceIP = destinationIP) |
|
Matches if the string passed is LIKE the
passed value and is not case sensitive. Use |
SELECT * FROM events WHERE userName ILIKE '%bob%' |
|
Matches if the string matches the provided regular expression and is not case sensitive. |
SELECT * FROM events WHERE userName IMATCHES '^.bob.$' |
|
Limits the number of results to the provided number. |
SELECT * FROM events LIMIT 100 START '2015-10-28 10:00' STOP '2015-10-28 11:00' Note:
Place the LIMIT clause in front of a |
|
Matches if the string passed is |
SELECT * FROM events WHERE userName LIKE '%bob%' |
|
Matches if the string matches the provided regular expression. |
SELECT * FROM events WHERE userName MATCHES '^.bob.$' |
|
Takes in a value and returns true if the value is not null. |
SELECT * FROM events WHERE userName IS NOT NULL |
|
Takes the left side of a statement and the right side of a statement and returns true if either side is true. |
SELECT * FROM events WHERE (sourceIP = destinationIP) OR (sourcePort = destinationPort) |
|
Full-text search for the passed value. TEXT SEARCH is valid with Place TEXT SEARCH in the first position of the WHERE clause. You can also do full-text searches by using the Quick filter in the JSA user interface. For information about Quick filter functions, see the Juniper Secure Analytics Users Guide. |
SELECT * FROM events WHERE TEXT SEARCH 'firewall' AND sourceip='192.168.1.1' SELECT sourceip,url FROM events WHERE TEXT SEARCH 'download.cdn.mozilla.net' AND sourceip='192.168.1.1' START '2015-01-30 16:10:12' STOP '2015-02-22 17:10:22' |
The following table lists the supported logical and comparison operators.
Examples Of Logical and Comparative Operators
To find events that are not parsed, type the following query:
SELECT * FROM events WHERE payload = 'false'
To find events that return an offense and have a specific source IP address, type the following query:
SELECT * FROM events WHERE sourceIP = '192.0.2.0' AND hasOffense = 'true'
To find events that include the text "firewall", type the following query:
SELECT QIDNAME(qid) AS EventName, * FROM events WHERE TEXT SEARCH 'firewall'