您的位置:首页 > 产品设计 > UI/UE

sql 对应 sequelize

2016-02-29 14:32 495 查看
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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: