db.WorkbookQuestion.count({ where: { QuestionId: dbQuestion.id,AnswerSelectedId: db.sequelize.col('CorrectAnswerId') } });
查询生成此sql:SELECT count(*)AS“count”FROM“WorkbookQuestions”AS“WorkbookQuestion”WHERE“WorkbookQuestion”.“QuestionId”= 1103 AND“CorrectAnswerId”;
我如何让它更像AnswerSelectedId = CorrectAnswerId?
你可以通过sequelize.where()来做到这一点:
原文链接:https://www.f2er.com/postgresql/191854.htmldb.WorkbookQuestion.count({ where: sequelize.where( db.sequelize.col('CorrectAnswerId'),db.sequelize.col('AnswerSelectedId') ) });