提问者:小点点

如何使用后遗症来完成这个请求?


我想知道使用Sequelize执行此请求所要编写的代码:

select * from "Songs" 
where Id in (
    select "songId" from "Likes"
    where "userId"=1
)

共1个答案

匿名用户

Songs.findAll({
    attributes: {
        include: [
            [
                // Note the wrapping parentheses in the call below!
                sequelize.literal(`(
                    select "songId" from "Likes"
                       where "userId"=1
                )`),
                'SongId'
            ]
        ]
    }
});

您可以尝试上面的内容作为参考参见此处