[英]Kusto KQL equivalent to LIKE CONCAT column with value (mysql)
我正在尝试翻译以下 MySQL (v5.6) 查询:
SELECT name FROM world WHERE capital LIKE CONCAT(name, '%city')
进入 Kusto KQL,但以下不起作用:
world | where capital matches regex strcat(name,".*city") | project name
可能是因为matches regex
只接受一个字符串值,而concat(name,".*city")
是一列。
即使以下也不起作用:
world | extend a = strcat(name, ".*City") | where capital matches regex a
关于如何将此查询转换为 KQL 的任何建议?
matches regex
的参数必须是标量字符串常量,并且可以取决于行上下文。
如果您可以对实际数据做出任何假设,您可能根本不需要使用正则表达式,并且有大量字符串运算符可供选择(当然取决于数据和要求): https:/ /docs.microsoft.com/en-us/azure/kusto/query/datatypes-string-operators
例如:
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"
结果与:
| 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.