0
我有以下查詢我想2個條件參加2個表(「產業」,‘國家’),但它給了我下面的錯誤MySQL的:加入多個表
錯誤代碼:1054 'on條款'中未知列'i.id'
有沒有人知道我應該如何解決這個問題?
SELECT c.name AS country_name, i.name as industry_name, num_projects, num_consultants, admin_rating
FROM industry i, country c
JOIN (SELECT pc.country_id, pi.industry_id, COUNT(p.id) AS num_projects
FROM project p, project_country pc, project_industry pi
where p.id = pc.project_id and pi.project_id=p.id
GROUP BY pc.country_id,pi.industry_id) x ON x.country_id = c.id and x.industry_id=i.id
JOIN (SELECT u.country_id,ie.industry_id, COUNT(u.id) AS num_consultants
FROM user u, consultant_profile, industry_experience ie
WHERE u.is_active = 1 AND u.type = 0 and
ie.consultant_profile_id= consultant_profile.id
and u.id= consultant_profile.id
GROUP BY u.country_id,ie.industry_id) y ON y.country_id = c.id and y.industry_id = i.id order by num_projects DESC limit 20;
編輯表結構如下:
- 行業 - ID
- project_industry - industry_id,PROJECT_ID
- industry_experience - consultant_profile_id,industry_id
- consultant_profile - ID邀請,USER_ID
'工業'表有'id'列嗎? – Sadikhasan
你有沒有在行業表 – Mujahidh
列名叫ID?你可以請張貼你的行業表列嗎? – Mujahidh