在SQL中,我可以用逻辑(true和true)或(true和true)编写查询,即:
select * from t1 inner join t2 on ... where (t1.a != t2.a and t1.b != t2.b) or (t1. != t2.a and t1.b != t2.b)
当我尝试像这个一样在Q中进行时
select from ej[....] where (t1.a != t2.a and t1.b != t2.b) or (t1. != t2.a and t1.b != t2.b)
它无法编译。
我也试过这个
(t1.a != t2.a and t1.b != t2.b) or (t1. != t2.a and t1.b != t2.b)
但是也没有返回正确的结果
如何在KDB中查询?
试试这个(在伪代码中):
( (t1.a != t2.a) and (t1.b != t2.b) ) or ( (t1.a != t2.a) and (t1.b != t2.b) )
Kdb/Q读取右侧的左侧,因此它处理
t1.a != t2.a and t1.b != t2.b
作为
t1.a != (t2.a and t1.b != t2.b)
而不是
(t1.a != t2.a) and (t1.b != t2.b)
除非您明确使用括号