I have a query that joins 5 tables to pull out the relevent results.
SELECT *
FROM publications, publicationsXpeople as pxp, people, publicationsXprojects as xpx, projects
WHERE publications.publication_code = pxp.publication_code
AND pxp.people_code = people.people_code
AND publications.publication_code = xpx.publication_code
AND xpx.project_code = projects.project_code
AND publications.publication_code = 7075
My problem is that whatever the number of results in one table , say the people table , the result from the projects table is duplicated to match.
So if i have 1 project that get pulled from the query and 3 people that get pulled from the query them my 3 people will be listed and the one project will be listed 3 times.
I'm finding this rather frustrating as the query pulls out the correct data its just i'm stuck with how it is displayed.
Could anyone shed some light on this?...
Here is the php that i am using to display the results if this is of any help.
while ($row =mysql_fetch_array($result)){
$publication_code = $row['publication_code'];
$publication_category=$row['publication_category'];
$publication_number=$row['publication_number'];
$publication_details=$row['publication_details'];
$publication_abstract=$row['publication_abstract'];
$publication_topic = $row['publication_topic'];
$publication_date_elements = explode("-",$row['publication_date']);
$sql_publication_date = $publication_date_elements[2]."-".$publication_date_elements[1]."-".$publication_date_elements[0];
$file_name=$row['file_name'];
$publication_url=$row['publication_url'];
$status=$row['status'];
//pertaining to people table
$publicationsXpeople_id=$row['publicationsXpeople_id'];
$people_code=$row['people_code'];
$pfirst_name=$row['first_name'];
$plast_name=$row['last_name'];
//pertaining tp projects table
$publicationXproject_id=$row['publicationXproject_id'];
$project_code=$row['project_code'];
$acronym=$row['acronym'];
$display_block .= "<table><tr><td>$plast_name $pfirst_name</td><tr></table>";
$display_block2 .= "<table><tr><td>$acronym</td><tr></table>";
}
}