Quote:
Originally Posted by eMonk
How would you have, for example, Monica displayed in Toronto, Chicago, New York and London under the models_cities table?
|
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.