Mattias
10/25/2021, 8:54 AMMattias
10/25/2021, 8:54 AM[{ product: "6" }]
using following query:
js
const res = await pool.query(`
SELECT product
FROM order_
WHERE customer = $1
`, [id]);
How do I get the name of the product instead of the id? [{ product: "Cloud potatoes" }]
I have a table called 'product' with following columns: id, name and price.Mattias
10/25/2021, 9:09 AMjs
const res = await pool.query(`
SELECT product
FROM order_
INNER JOIN product
ON product.id = order_.id
WHERE customer = $1
`, [id]);
Mattias
10/25/2021, 12:07 PMjs
const res = await pool.query(`
SELECT name
FROM product
INNER JOIN order_
ON product.id = order_.product
WHERE customer = $1
`, [id]);