Conditional Upsert

Hi Guys, 

Whats the best way to conditionally upsert two tables?  For example if I have two tables

t:sym xkey flip (symval)!(abc;(1;3;5))t1:sym xkey flip (symval)!(bcd;(8;1;9))

and I want to only update values in table t when there is a higher value in table t1, so final table should be

sym vala 1b 8c 5d 9

I know change col name of t1,  uj them, then check which value is higher 

select val:last max(val;val1) by sym from (t uj (select val1:last val by sym from t1))

but it seems like there should be a better way

Thanks

q)max(t;t1)sym| val—| —a | 1b | 8c | 5d | 9On Wed, Sep 27, 2017 at 9:48 PM, Roni Hoffman wrote:> Hi Guys,>> Whats the best way to conditionally upsert two tables? For example if I> have two tables>> t:sym xkey flip (symval)!(abc;(1;3;5))> t1:sym xkey flip (symval)!(bcd;(8;1;9))>> and I want to only update values in table t when there is a higher value in> table t1, so final table should be>> sym val> a 1> b 8> c 5> d 9>> I know change col name of t1, uj them, then check which value is higher>> select val:last max(val;val1) by sym from (t uj (select val1:last val by sym> from t1))>>> but it seems like there should be a better way>> Thanks>> –>

Submitted via Google Groups

q)t|t1

sym| val

—| —

a  | 1

b  | 8

c  | 5

d  | 9

q)t|:t1

q)t

sym| val

—| —

a  | 1

b  | 8

c  | 5

d  | 9

haha :| , ok thanks