Got Haggis?
Veteran XX
what is the best statement to do this
I can only pass a topic_id to the sql statement
I have 5 tables
topics, materials, materials_topics, languages, and producers
topics has topic_id, and topic
materials has material_id and a bunch of other text fields i need
materials_topics has material_id and topic_id
languages has material_id and language
producers has material_id and producer
So, what I need to do is, based on topic_id (for example lets say a topic id of 2) I need to get all materials that have a topic_id of 2, then get its material_id and display all the info from the 3 different tables (materials, languages, and producers) that has the same material_id
i tried doing this using a LEFT JOIN and it crashed the server, so i guess i'm off somehwere. i suck at sql anyway. something like this
how can i fix this to run and not crash the server ?
I can only pass a topic_id to the sql statement
I have 5 tables
topics, materials, materials_topics, languages, and producers
topics has topic_id, and topic
materials has material_id and a bunch of other text fields i need
materials_topics has material_id and topic_id
languages has material_id and language
producers has material_id and producer
So, what I need to do is, based on topic_id (for example lets say a topic id of 2) I need to get all materials that have a topic_id of 2, then get its material_id and display all the info from the 3 different tables (materials, languages, and producers) that has the same material_id
i tried doing this using a LEFT JOIN and it crashed the server, so i guess i'm off somehwere. i suck at sql anyway. something like this
Code:
SELECT materials.*, languages.*, producers.*, materials_topics.material_id FROM tools_materials
LEFT JOIN materials_topics
ON materials.material_id = materials_topics.material_id
WHERE materials_topics.topic_id = '$topic_id' AND
languages.material_id = materials_topics.material_id AND
producers.material_id = materials_topics.material_id
how can i fix this to run and not crash the server ?