比较kdb中的两个符号字段。

huangapple go评论54阅读模式
英文:

compare two symbol fields in kdb

问题

以下是翻译好的部分:

我想要在KDB+中比较两个字段。
在同一行上,一个字段包含另一个字段的值

例如。

tab:([]col1:`abc`bcd`efd;col2:`$("/ee/abc/uuu");`$("/ee/abc/uuu");`$("/ee/efd/uuu"))
我想要提取第一行和第三行,因为col1的值与同一行的col3中的值匹配

到目前为止,我得到了以下结果:

select from tab where any (string col1) like/: (string col2)
但是它没有返回任何内容。
英文:

I would like to compare two fields in KDB+.
so on the same row, one field contains another fields value

eg.

tab:([]col1:`abc`bcd`efd;col2:`$("/ee/abc/uuu");`$("/ee/abc/uuu");`$("/ee/efd/uuu"))

I would like to extract first and third rows because col1 values are in col3 on the same row

This is what I got so far:

 select from tab where any (string col1) like/: (string col2)

However it did not return anything.

答案1

得分: 2

以下是已翻译的内容:

假设您在两侧都使用通配符(使用"*"):

tab:([]col1:`abc`bcd`efd;col2:`$("/ee/abc/uuu";"/ee/abc/uuu";"/ee/efd/uuu"));
q)select from tab where col2 like '("*',string[col1],'*")
col1 col2
----------------
abc  /ee/abc/uuu
efd  /ee/efd/uuu
英文:

Assuming you're wildcarding it on both sides (with "*"):

q)tab:([]col1:`abc`bcd`efd;col2:`$("/ee/abc/uuu";"/ee/abc/uuu";"/ee/efd/uuu"));
q)select from tab where col2 like'("*",'string[col1],'"*")
col1 col2
----------------
abc  /ee/abc/uuu
efd  /ee/efd/uuu

huangapple
  • 本文由 发表于 2023年8月5日 05:05:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76839100.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定