
January 8th, 2013, 03:13 PM
|
|
Me
|
|
Join Date: Apr 2007
Location: San Diego, CA
Posts: 2,263
 
Time spent in forums: 2 Weeks 1 Day 5 h 51 m 8 sec
Reputation Power: 9
|
|
based on the tables you described, just users, events, and products tables, you would probably just want to add a user_id to the products table and then make a join table that has the product id and the event id. from there to get all products of a specific user, you can just do:
Code:
SELECT *
FROM Products
WHERE user_id=:user_id
and to get the products a specific user is bringing to a specific event:
Code:
SELECT *
FROM Products
JOIN Products_Events
ON Products.ID=Products_Events.Product_ID
JOIN Events
ON Events.ID=Products_Events.Event_ID
JOIN Users
ON Users.ID=Products.User_ID
WHERE
Users.ID=:user_id
AND Event.ID=:event_id
|