3

I can do this:

x:([]v: 4 2; w: 10 100)
x: update z:`test from x where v = 4
x

But i'd really like to be able to do the conditional update and select all in one hit. something like

select v, w, (select `test from x where v = v) from z

Is this possible in kdb?

Thomas Smyth - Treliant
  • 4,993
  • 6
  • 25
  • 36

2 Answers2

4

You could try

update z:?[v=4;`test;`] from x
emc211
  • 1,369
  • 7
  • 14
3

Is the vector conditional if what you're looking for?

q)select v,w,z:?[v=4;`test;`] from x
v w   z
----------
4 10  test
2 100

http://code.kx.com/q/ref/lists/#vector-conditional

jomahony
  • 1,662
  • 6
  • 9