如何动态拼接SQL以实现udpate a = 2 from ej(t1,t2,`id)的效果

请先 登录 后评论

1 个回答

Juntao Wang

使用sqlUpdateparseExpr 元编程函数,示例如下:

t1 = table(`A`A`B`B as symbol, 2021.04.15 2021.04.16 2021.04.15 2021.04.16 as date, 12 13 21 22 as price)
t2 = table(`A`A`B`B as symbol, 2021.04.15 2021.04.16 2021.04.15 2021.04.16 as date, 10 20 30 40 as price)
colName = "price"
tableName = "t2"
updates = tableName + "." + colName + " as " + colName
sqlUpdate(table=t1, updates=parseExpr(updates), from=<ej(t1, t2, `symbol`date)>).eval()
请先 登录 后评论