Jump to content

Recommended Posts

I have 3 tables and need to pull info from each.

 

Members

- member_id

- first_name

- last_name

- agdnumber

 

Evaluations

- eval_id

- credit_hours

- course_title

 

Evals_completed

- member_id

- eval_id

 

I need to create a list of all the members and the evals that they have taken but only show members that have an entry in the column 'agdnumber' from the members table.

 

 

Example of list needed:

 

Dr. John Smith (from members)

12345 (agdnumber from members)

Advances in Soft Tissue Grafting for Implants - 1.5 credit hours (from evaluations)

Going Green in Dentistry - 3 credit hours (from evaluations)

 

Dr. Sam Morgan

12345 (agd number)

Advances in Soft Tissue Grafting for Implants - 1.5 credit hours (from evaluations)

Going Green in Dentistry - 3 credit hours (from evaluations)

 

Thank you for any advise.

 

Link to comment
https://forums.phpfreaks.com/topic/232195-need-some-help-from-the-prosplease/
Share on other sites

you would have to use two JOINs

 

somethign like this.

 

SELECT
`members`.`firstname`,
`members`.`lastname`,
`members`.`agdnumber`,
`evaluations`.`cource_title`,
`evaluations`.`credit_hours`
FROM `members`
INNER JOIN `evals_completed`
ON `members`.`member_id` = `evals_completed`.`member_id`
INNER JOIN `evaluations`
ON `evals_completed`.`eval_id` = `evaluations`.`eval_id`

 

untested (because I don’t have that database) but it should work

http://dev.mysql.com/doc/refman/5.0/en/join.html

 

This isn't rocket-surgery:

 

SELECT e.credit_hours, e.course_title, ec.agdnumber, ec.first_name, ec.last_name
FROM evals_completed ec
JOIN evaluations e USING(eval_id)
JOIN members m USING(member_id)
WHERE ec.agdnumber IS NOT NULL

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.