View Single Post
Old 03-12-2011, 09:30 AM  
eMonk
Confirmed User
 
Industry Role:
Join Date: Aug 2003
Location: Canada
Posts: 2,310
Quote:
Originally Posted by k0nr4d View Post
You would insert multiple models_cities entries per model.

So lets say Toronto = 123
Chicago = 456
New York = 789

INSERT INTO models_cities (model, city) VALUES (modelid,123);
INSERT INTO models_cities (model, city) VALUES (modelid,456);
INSERT INTO models_cities (model, city) VALUES (modelid,789);

SELECT model.* FROM model WHERE model.model_id = model_in_city.model_id AND model_in_city.city_id = city.city_id AND city.city_name = "Toronto"
SELECT model.* FROM model WHERE model.model_id = model_in_city.model_id AND model_in_city.city_id = city.city_id AND city.city_name = "Chicago"
SELECT model.* FROM model WHERE model.model_id = model_in_city.model_id AND model_in_city.city_id = city.city_id AND city.city_name = "New York"

Will then all return the same model

Edit: well, insert using your actual table and column names i just wrote those inserts quickly to show you.
Ah thanks bro. I'll try this tonight or tomorrow. I was thinking along the lines of:

VALUES (modelid, 123, 456, 789, ...);

Which you can't do from my understanding (multiple values in column). I searched google and my book for reference but couldn't find anything on this. Thanks again!

Last edited by eMonk; 03-12-2011 at 09:31 AM..
eMonk is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote