
where command usage
The where
command is identical to the WHERE
clause in the from command.
Typically you use the where
command when you want to filter the result of an aggregation or a lookup.
Using wildcards
You can use wildcards to match characters in string values. With the where
command, you must use the like
function.
- Use the percent ( % ) symbol as a wildcard for matching multiple characters
- Use the underscore ( _ ) character as a wildcard to match a single character
In this example, the where
command returns search results for values in the ipaddress
field that start with 198.
... | where like(ipaddress, "198.%")
See the like (<str>, <pattern>) function in the list of Comparison and Conditional eval functions.
Comparing two fields
One advantage of the where
command is that you can use it to compare two different fields. You cannot do that with the search
command. Here are some examples:
Command | Example | Description |
---|---|---|
Where |
|
This search looks for events where the field foo is equal to the field bar .
|
Where |
|
This search looks for events where the field foo is equal to the field bar-baz . Because the field bar-baz contains a character that is not a-z, A-Z, 0-9, or and underscore ( _ ), it must be enclosed in single quotation marks.
|
Search |
|
The search command handles these expressions as a field=value pair. In this example, The bar is interpreted as a string value.
|
Where |
|
This search looks for events where the field foo contains the string value bar .
|
Predicate expressions
The order in which predicate expressions are evaluated with the where
command is:
- Expressions within parentheses
- NOT clauses
- AND clauses
- OR clauses
The where
command evaluation order is different than the evaluation order used with the search
command. The search
command evaluates OR clauses before AND clauses.
Functions
You can use a wide range of functions with the where
command. See Overview of SPL2 eval functions.
See also
- Other commands
- search command overview
PREVIOUS where command syntax details |
NEXT where command examples |
This documentation applies to the following versions of Splunk® Cloud Services: current
Feedback submitted, thanks!