How do I fix this so as to achieve my desired output regardless of if the product has a review assigned to it.
Thank you
ANSWERED
CodePudding user response:
You are doing an inner join, which only returns rows where the productID matches in both tables. You need to do a left join so that if the productID does not exist in the review table, the matching row in the product table will still be returned.
CodePudding user response:
Kindly use LEFT JOIN instead.
SELECT product.name, product.image, product.description, product.brand, product.price, review.rating
FROM product LEFT JOIN review
ON product.productid = review.productid
WHERE product.name = ?
