我有一个查询在MS SQL Server上工作,但没有在MySQL上工作:
SELECT ppmap_d.*, p_prob.*, ppmap_h.*, p_probgroup.*,
p_prod.*, ppmap_d.prob_id AS probid, ppmap_d.map_id AS mapid,
ppmap_h.pg_name AS probgname, ppmap_h.m_id AS modelid
FROM p_prob
INNER JOIN p_prod
INNER JOIN ppmap_h
INNER JOIN ppmap_d
INNER JOIN p_probgroup
ON ppmap_d.prob_id = p_probgroup.prob_id
ON ppmap_h.map_id = ppmap_d.map_id AND ppmap_h.pg_name = p_probgroup.pg_name
ON p_prod.m_id = ppmap_h.m_id
ON p_prob.prob_id = p_probgroup.prob_id;
我做错了什么?
以下查询是正确的,但会导致错误:
SELECT ppmap_d.*, p_prob.*
FROM ppmap_d INNER JOIN p_probgroup
ON ppmap_d.prob_id = p_probgroup.prob_id;
错误:
SELECT ppmap_d。,p_prob。 FROM ppmap_d INNER JOIN p_probgroup ON ppmap_d.prob_id = p_probgroup.prob_id LIMIT 0,25 MySQL说:文档
1051 - 未知表' dbeshop.p_prob'
答案 0 :(得分:3)
SELECT ppmap_d.*, p_prob.*, ppmap_h.*, p_probgroup.*,
p_prod.*, ppmap_d.prob_id AS probid, ppmap_d.map_id AS mapid,
ppmap_h.pg_name AS probgname, ppmap_h.m_id AS modelid
FROM p_prob
INNER JOIN p_prod ON ppmap_d.prob_id = p_probgroup.prob_id
INNER JOIN ppmap_h ON ppmap_h.map_id = ppmap_d.map_id AND ppmap_h.pg_name = p_probgroup.pg_name
INNER JOIN ppmap_d ON p_prod.m_id = ppmap_h.m_id
INNER JOIN p_probgroup ON p_prob.prob_id = p_probgroup.prob_id;