Jump to content

Need help with LEFT JOIN


eMonk

Recommended Posts

I'm trying to list all the models listed in the province British Columbia. Here's my tables:

 

Table: model
column: id = 1,2

Table: city
column: city_id = 33,34
column: city_name = Vancouver,Victoria
column: province_id = 9,9

Table: model_in_city
column: model_id = 1,2
column: city_id = 33,34

Table: province
column: id = 9,10
column: name = British Columbia,Quebec

 

I believe these are the conditions that are needed:

 

model.id = model_in_city.model_id

city.city_id = model_in_city.city_id

city.province_id = province.id

WHERE province.name = British Columbia

 

I tried the following query but can't seem to LEFT JOIN 2 tables?

 

SELECT id from model
LEFT JOIN model_in_city ON (model_in_city.model_id = model.id)
LEFT JOIN city ON (city.province_id = province.id);

 

MySQL said:

 

#1054 - Unknown column 'province.id' in 'on clause'

Link to comment
https://forums.phpfreaks.com/topic/252980-need-help-with-left-join/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.