在这行SELECT po.*, du."displayName", du."email" FROM partner_orders as po, ds_user as du WHERE id = ${program.id}
中,我一直得到错误列引用"id"是模棱两可的,我怎么解它?
async getAllParenFinanceOrders() {
const programOrders = await pool.query(
`SELECT po.*, du."displayName", du."email"
FROM partner_orders AS po
LEFT JOIN ds_user AS du ON du.id = po."dsUserId" `
);
console.log("programOrders...", programOrders)
const partnerPrograms = await Promise.all(
programOrders.rows.map(async program => {
const query = await pool.query(
`SELECT po.*, du."displayName", du."email" FROM partner_orders as po, ds_user as du WHERE id = ${program.id}`
);
console.log('query.rows[0]...', query.rows[0])
return query.rows[0];
})
);
return {
programs: partnerPrograms
};
}
不确定这里需要的是哪个表id,但需要添加一个表id作为前缀:
SELECT po.*, du."displayName", du."email" FROM partner_orders as po, ds_user as du WHERE id = ${program.id}`
);
需要重写为
SELECT po.*, du."displayName", du."email" FROM partner_orders as po, ds_user as du WHERE po.id = ${program.id}`
);
或
SELECT po.*, du."displayName", du."email" FROM partner_orders as po, ds_user as du WHERE du.id = ${program.id}`
);
使错误消失。