作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
在 DataJoint for Python 中,fetch
命令中使用的 ORDER BY 参数的正确语法是什么?
current documentation (as of 2018-08-17) 只在 MATLAB 中为 DataJoint 指定了以下语法:
s = fetch(experiment.Session, '*', 'ORDER BY session_date DESC LIMIT 5')
最佳答案
在 Python 中,ORDER BY 参数的正确语法是
table.fetch(order_by='attr')
如果您需要按多个属性排序,请将它们作为元组提供:
table.fetch(order_by=('attr1', 'attr2'))
这将根据指定的属性按升序对获取的项目进行排序。要使其降序,请将单词 DESC
添加到属性中。
table.fetch(order_by='attr DESC')
table.fetch(order_by=('attr1 DESC', 'attr2'))
您也可以选择使用单词 ASC
来使升序隐含,但省略它具有相同的效果。
关于python - DataJoint for Python 中正确的 ORDER BY 语法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51902970/
我是一名优秀的程序员,十分优秀!