Rik Comery
09-10-2003, 03:05 AM
Hi. I am very new to this so please forgive my ignorance.
I have two tables in a database. One called "Clients" and the other called "Clients_Docs". The tables contain the following fields. (i have excluded many as they are irrelivant for this question).
Clients
ID (primary)
First_Name
Surname
etc
Clients_Docs
DocID (primary)
ID
Document_Type
etc
To accompany this, i have a PHP form which populates the Clients table, and gives the entry a unique id in the ID field. Once a client has been added, i have a type of update form where you can add different document types for that client. This information is written to the Clients_Docs table and inserts the unique ID value from the first table into the ID field.
This all works fine. My problem is when i try to create a query. If i search for any field in the Clients table, the results are fine, but how do i select from both tables.
for example, i may want to find all clients whose first name is Rik, and have been sent a prospectus document. (first name is in Clients table and prospectus document is in Clients_Docs)
I have tried to use a join in my select query, but to be honest, i have not found information on this that is easy to understand. As i said, i am new to this.
Can anyone help please.
I have two tables in a database. One called "Clients" and the other called "Clients_Docs". The tables contain the following fields. (i have excluded many as they are irrelivant for this question).
Clients
ID (primary)
First_Name
Surname
etc
Clients_Docs
DocID (primary)
ID
Document_Type
etc
To accompany this, i have a PHP form which populates the Clients table, and gives the entry a unique id in the ID field. Once a client has been added, i have a type of update form where you can add different document types for that client. This information is written to the Clients_Docs table and inserts the unique ID value from the first table into the ID field.
This all works fine. My problem is when i try to create a query. If i search for any field in the Clients table, the results are fine, but how do i select from both tables.
for example, i may want to find all clients whose first name is Rik, and have been sent a prospectus document. (first name is in Clients table and prospectus document is in Clients_Docs)
I have tried to use a join in my select query, but to be honest, i have not found information on this that is easy to understand. As i said, i am new to this.
Can anyone help please.