OCT-DEVELOPERS OCT-DEVELOPERS - 1 month ago 14
MySQL Question

MS SQL query not working on MySQL

I have a query working on MS SQL Server, but not working on 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;


What did I do wrong?

The query below is correct but results in an error:

SELECT ppmap_d.*, p_prob.*
FROM ppmap_d INNER JOIN p_probgroup
ON ppmap_d.prob_id = p_probgroup.prob_id;


Error:


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 said: Documentation

1051 - Unknown table 'dbeshop.p_prob'

Answer
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;
Comments