kdb - KDB:如何使用一组列进行查询
问题描述
我该如何做这个相应的 SQL 查询:
select * from a where (col1, col2) in (select x, y from b)
所以如果我有
p:([]name:`John`Mary`David`James; age:52 49 18 23; hair:("black";"black";"blonde";"black"); eyes:`brown`brown`blue`brown; aa:("hello";"world";"hi";"there"))
我如何使这个查询工作:
select from p where (hair, eyes) in (
select hair, eyes from p where any aa like/:("hello";"hi")
)
解决方案
的输出select hair, eyes from p where any aa like/:("hello";"hi")
是一个表,因此我们需要为所需的 where 语句从hair
和列创建一个表:eyes
q)select from p where ([]hair;eyes) in select hair, eyes from p where any aa like/:("hello";"hi")
name age hair eyes aa
--------------------------------
John 52 "black" brown "hello"
Mary 49 "black" brown "world"
David 18 "blonde" blue "hi"
James 23 "black" brown "there"
推荐阅读
- java - Log4j2 自动翻转调度程序
- ethereum - 如何解决松露迁移错误?
- linux - 比较两个单词,第一个单词 = 附加日期的文件名,第二个单词 = 仅日期。比较应该显示具有不同日期的行
- ionic3 - 如何在离子 3 中的 leaflet.map("map").setView 中使用当前纬度
- python - 将动态字段添加到 django-rest-framework 中的序列化程序
- mysql - 如何修复 mysql 中的“ERROR 1241 (21000): Operand should contain 1 column(s)”?
- node.js - 'Isms91Options' 类型的参数不能分配给'string | 类型的参数 网址'
- oracle - Oracle 存储过程的返回值
- visual-studio-code - 将结果保存在 Azure DevOps 中 vscode-extension 单元测试的文件中
- javascript - 如何使 Html 表格列可编辑?