作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个包含 100 多列的表,我想查询除第一列和第二列以外的所有列。如何在不枚举 100 列的情况下快速完成?
仅出于说明目的,假设我有这个包含 6 列的表格:
t = table(1..3 as col1, 1..3 as col2, 1..3 as col3, 1..3 as col4, 1..3 as col5, 1..3 as col6)
t
输出:
col1 col2 col3 col4 col5 col6
1 1 1 1 1 1
2 2 2 2 2 2
3 3 3 3 3 3
如何从表中选择除前 2 列以外的所有列?
最佳答案
您可能会发现 DolphinDB 元编程对您的情况有帮助 (metaprogramming technique in DolphinDB)。
继续你的例子,试试这个脚本:
colNames = t.schema().colDefs.name
// assuming you don't want col1 and col2
select_cols = colNames[at(!(colNames in [`col1, `col2]))]
res = sql(sqlCol(select_cols), t).eval()
打印资源:
col3 col4 col5 col6
1 1 1 1
2 2 2 2
3 3 3 3
关于sql - 一次在 SQL 查询中选择 100 多个列(但不是所有表列)的便捷方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74567600/
我是一名优秀的程序员,十分优秀!