JOIN 查询在 Node-postgres 中不起作用

JOIN queries not working in Node-postgres

我正在尝试使用 Node-PostgreSQL 一起查询两个关系 table,但出现语法错误:

    ;(async () => {
        const client = await pool.connect()
        try {
          const res = await client.query('SELECT * FROM "Booking" JOIN "User" ON "User.id"="Booking.renter"')
          console.table(res.rows)
        } finally {
          client.release()
        }
      })().catch(err => console.log(err.stack)) 

Booking table 和 User table 由 Booking.renter 列和 User.id 列连接,但上面的代码显示:

error: column "User.id" does not exist

查询单个 table 工作正常:

   const res = await client.query('SELECT * FROM "Booking"')

您应该单独包装您的 table.column

const res = await client.query('SELECT * FROM "Booking" JOIN "User" ON "User"."id"="Booking"."renter"')