[英]Kusto KQL equivalent to LIKE CONCAT column with value (mysql)
I'm trying to translate the following MySQL (v5.6) query:我正在尝试翻译以下 MySQL (v5.6) 查询:
SELECT name FROM world WHERE capital LIKE CONCAT(name, '%city')
into Kusto KQL, but the following doesn't work:进入 Kusto KQL,但以下不起作用:
world | where capital matches regex strcat(name,".*city") | project name
Probably since the the matches regex
takes only a string value, and concat(name,".*city")
is a column.可能是因为
matches regex
只接受一个字符串值,而concat(name,".*city")
是一列。
Even the following doesn't work:即使以下也不起作用:
world | extend a = strcat(name, ".*City") | where capital matches regex a
Any suggestions to how I can translate this query to KQL?关于如何将此查询转换为 KQL 的任何建议?
The argument to matches regex
must be a scalar string constant, and can depend on row context. matches regex
的参数必须是标量字符串常量,并且可以取决于行上下文。
If you can make any assumptions on the actual data, you may not need to use a regular expression at all, and have a wide set of string operators to choose from (depending on the data and the requirement, of course): https://docs.microsoft.com/en-us/azure/kusto/query/datatypes-string-operators如果您可以对实际数据做出任何假设,您可能根本不需要使用正则表达式,并且有大量字符串运算符可供选择(当然取决于数据和要求): https:/ /docs.microsoft.com/en-us/azure/kusto/query/datatypes-string-operators
For example:例如:
let world = datatable(capital:string)
[
"Belize City",
"Jeruslam",
"Mexico City",
"Tulum",
"NotARealCity"
]
;
world
| extend _ends_with = capital endswith "city",
_has = capital has "city",
_contains = capital contains "city"
Results with:结果与:
| capital | _ends_with | _has | _contains |
|--------------|------------|------|-----------|
| Belize City | 1 | 1 | 1 |
| Jeruslam | 0 | 0 | 0 |
| Mexico City | 1 | 1 | 1 |
| Tulum | 0 | 0 | 0 |
| NotARealCity | 1 | 0 | 1 |
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.