【问题标题】:How to select DISTINCT rows in mySQL DB using NodeJs ORM module?如何使用 NodeJs ORM 模块在 mySQL DB 中选择 DISTINCT 行?
【发布时间】:2014-09-17 09:38:34
【问题描述】:

我正在为我的数据库工作使用 NodeJs 的 orm2 模块,但我被困在需要从 MYSQL 中选择不同行的地方。

提前致谢。

【问题讨论】:

    标签: mysql sql node.js orm


    【解决方案1】:

    根据这个pull request,你可以这样做:

    Person.aggregate().distinct('country').get(function (err, countries) {
        // countries should be an Array like [ 'country1', 'country2', ... ]
    });
    

    【讨论】:

    • 谢谢它正在工作,但它显示无法创建未定义的别名,当我删除 .as() 时它工作正常,否则它给出名为 distinct_country 的列
    猜你喜欢
    • 2014-10-12
    • 1970-01-01
    • 2014-08-04
    • 1970-01-01
    • 1970-01-01
    • 2015-03-26
    • 1970-01-01
    • 2011-10-08
    • 2020-11-03
    相关资源
    最近更新 更多