|
Question : Query to match client with worker and goals
|
|
Hello Experts and thank you for looking at my issue. I have three tables Clients, Workers and Goals. I am trying to produce a report that prints out a form. The form should have the Client Name, Worker Name and a list of goals for that client. A client can have only one worker but many goals. My problem is building a query. The three tables have a Client Number in common. Using Client Number I can match a client with a worker but when I try to match a client with their goals I get multiple instances of the same goal. I have tried both left and right joins.
Additionally, when I produce the report how would I list multiple goals when the goals exist in seperate records?
Please let me know if you need more information. Thanks!
|
|
Answer : Query to match client with worker and goals
|
|
Your query has to look like this:
SELECT Clients.*, Workers.*,Goals.* FROM Clients INNER JOIN Workers ON Clients.ClientID = Workers.ClientID INNER JOIN Goals ON Clients.ClientID = Goals.ClientID;
In fact you can limit the fields you want from each table, but you want to join Clients to both Workers and Goals
|
|
|
|