Hello
I hope what I'm about to say will make sense
I have 5 tables. I shall list them now with the relevant field names
types with field: type_id
doc_types with fields: type_id and doc_id
documents with fields: doc_id , doc_title and doc_url
doc_consultees with fields: doc_id and consultee_id
consultees with field: consultee_id
I need to select the doc_title from the documents table that match up (using the id fields) to a particular type (in types table) and a particular consultee (in consultees table).
The code I have at the moment for selecting the information I want concerned with a particular type (not bothering about a particular consultee at this point) is
<?$dsn="conserve";
$username="sa";
$password="";
$connect = odbc_connect("conserve", "sa", "");
$result = odbc_exec($connect, "SELECT doc_url, doc_title
FROM documents INNER JOIN
(types INNER JOIN doc_types
ON types.type_id=doc_types.type_id)
ON doc_types.doc_id=documents.doc_id
WHERE types.type='".$POST['type_search']."'
AND doc_date_yr = '".$POST['year_search']."'");
while ($row = odbc_fetch_array($result))
{
echo '<ul><li><a href="' . $row['doc_url'] . '">' . $row['doc_title'] . '</a></li></ul>';
}
odbc_close($connect);
?>
this is all great and I am very grateful to another forum member for helping me with that
but now as I said above I want to not only pick a document that has a particular type but a particular consultee ASWELL.
So I tried to cheat by using the SQL that access produces when it performs a query
It gave me this: but it doesn't work
FROM consultees INNER JOIN ((documents INNER JOIN (types INNER JOIN doc_types ON types.type_id = doc_types.type_id) ON documents.doc_id = doc_types.doc_id) INNER JOIN doc_consultees ON documents.doc_id = doc_consultees.doc_id) ON consultees.consultee_id = doc_consultees.consultee_id;
I am having no luck with all the trial and error methoda that have occupied me for a couople of days now.
I just can't gt my head round mulltiple inner joins I'm afraid
Thanks for any help you can offer