sql 对应 sequelize

来源:互联网 发布:巨人网络借壳方案 编辑:程序博客网 时间:2024/06/05 05:14
sequelize调用distinct函数
xx.xx.findAll({where:begin_date,attributes:['DISTINCT `nb_id`']},SqlQureyFormat).complete(function(dberr, dbresult) {
}}
sql:SELECT DISTINCT `nb_id` FROM `xx` WHERE 1=1;


sequelize调用ORDER BY函数
xx.xx.findAll({where:{},'order': [['create_time', 'DESC']]},SqlQureyFormat).complete(function(dberr, dbresult) {
})

sql:SELECT * FROM `xx` WHERE 1=1 ORDER BY `create_time` DESC;


sequelize获取重复数据

xx.xx.findAll({where:{},'group': [['nb_id', 'having count>1']],attributes:['`nb_id`,count(nb_id) as count']},SqlQureyFormat).complete(function(dberr, dbresult) {
})

sql:SELECT `nb_id`,count(nb_id) as count FROM `xx` WHERE 1=1 GROUP BY `nb_id` having count>1;

1 0