I'm trying to query two relational tables together using Node-PostgreSQL, but getting a syntax error:
;(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))
The Booking table and the User table is joined by the Booking.renter column and the User.id column, but above code shows:
error: column "User.id" does not exist
Querying a single table works fine:
const res = await client.query('SELECT * FROM "Booking"')