MySQL查询:
SELECT categories.name AS CATEGORIES,GROUP_CONCAT(subcategories.name) AS
SUBCATEGORIES FROM subcategories INNER JOIN categories ON
subcategories.categorieName = categories.name GROUP BY categories.name;
答案 0 :(得分:0)
对于已经准备好的SQL查询,您可以使用函数sequelize.query
您可以尝试:
sequelize.query("SELECT categories.name AS CATEGORIES,GROUP_CONCAT(subcategories.name) AS SUBCATEGORIES FROM subcategories INNER JOIN categories ON subcategories.categorieName = categories.name GROUP BY categories.name")
.spread((results, metadata) => {
// Results will be an empty array
// and metadata will contain the number of affected rows.
})
您的参考,以获取更多详细信息:
http://docs.sequelizejs.com/manual/tutorial/raw-queries.html
我希望对您有帮助