我需要用一个只有一个符号的列表来更新一个列。低于1个不起作用。请注意,city是一个包含符号列表的列。
update city: enlist `Lodnon from `user where id in (1,2,3);发布于 2021-11-24 11:13:24
您当前的查询非常接近。您希望提供一个原子(即`london ),而不是列表:
update city:`london from user where id in 1 2 3
您建议的查询将失败,并出现长度错误(假设在1 2 3中有3条记录具有id,您将提供一个包含1个元素的列表来替换3个列条目)。
编辑:要获得实际的列值,您必须确保city列包含列表(即,将关键字meta应用于您的表应该在city的t列中返回大写S。
假设您的city列在运行meta user时当前有一个很小的s,您可以通过运行以下命令来更新它:
update city:enlist each city from `user
然后,以下内容将进行您想要的更改:
update city:city:\:enlist`london from user where id in 1 2 3
发布于 2021-11-24 11:38:09
如果你希望它仍然是一个列表,你可以这样做
{update city:(x)#enlist `london from `user where id in 1 2 3}count select from t where id in 1 2 3或者,要整理它,您可以使用
update city:count[i]#enlist `London from t where id in 1 2 3由于where子句中的过滤,计数中的i将与列表的长度相同。
发布于 2021-11-26 07:13:18
或者,您可以使用?[boolean_list;if_true;if_false]操作符,如下所示:
/ this is just to create a test table
t:([] id:(1;2;3;4); city:4#`)
/ check if each element of t`id is in (1;2;3)
/ 1) `London if true, ` if false
/ 2) assign t[`city]
t[`city]:?[in[t`id;(1;2;3)];`London;`]https://stackoverflow.com/questions/70094913
复制相似问题