I have two tables, one with products and a foreign key for the customer. The other is a watchlist with the product id and the fk for the customer.
How would I go about looping the product information from the products table where the fk matches the session id in the watchlist?
My mind is blank and google isn't helping!
Many thanks.
Example tables:
Products
--------
id (PK)
name
price
description
Customers
---------
id (PK)
firstName
lastName
email
phone
WatchList
---------
customerID (FK)
itemID (FK)
Get a customers watch list:
SELECT Products.name, Customers.email
FROM WatchList
JOIN Customers ON WatchList.customerID = Customers.ID
JOIN Products ON WatchList.itemID = Products.ID
WHERE Customers.ID = <insert customer id here>