2017-06-25 189 views

回答

0

假設你已經從定義到B

Model.A.findAll({where:{user_id:XXX}, include:Model.B}) 

如果沒有社團協會,您可以使用raw queries

sequelize.query('SELECT IFNULL(A.price, B.price) FROM table1 B INNER JOIN (SELECT price, product_id FROM table2 WHERE user_id=:uid) A ON A.product_id=B.product_id',{replacements:{uid:xxx}}) 
相關問題