1

In SQL I may write query with logical (true and true) or (true and true), i.e:

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)

when I try to do it in Q like this

select from ej[....] where (t1.a != t2.a and t1.b != t2.b) or (t1. != t2.a and t1.b != t2.b)

it fails to compile.

I have also tried this

(t1.a != t2.a and t1.b != t2.b) or (t1. != t2.a and t1.b != t2.b)

but it doesn't return the correct result either

How to query it in KDB?

Donald_W
  • 1,773
  • 21
  • 35
user3914448
  • 469
  • 1
  • 11
  • 22

1 Answers1

2

Try this (in pseudo-code):

( (t1.a != t2.a) and (t1.b != t2.b) ) or ( (t1.a != t2.a) and (t1.b != t2.b) )

Kdb/Q reads left-of-right so it treats

t1.a != t2.a and t1.b != t2.b

as

t1.a != (t2.a and t1.b != t2.b)

rather than

(t1.a != t2.a) and (t1.b != t2.b)

unless you explicity use brackets

terrylynch
  • 11,844
  • 13
  • 21