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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.