stackumhi Posted March 30, 2011 Share Posted March 30, 2011 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 More sharing options...
Maq Posted March 30, 2011 Share Posted March 30, 2011 So do you have a question? (Please be conscious of where you post this is clearly a SQL issue, not PHP Coding) Link to comment https://forums.phpfreaks.com/topic/232195-need-some-help-from-the-prosplease/#findComment-1194500 Share on other sites More sharing options...
betterphp Posted March 30, 2011 Share Posted March 30, 2011 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 Link to comment https://forums.phpfreaks.com/topic/232195-need-some-help-from-the-prosplease/#findComment-1194507 Share on other sites More sharing options...
ignace Posted March 30, 2011 Share Posted March 30, 2011 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 Link to comment https://forums.phpfreaks.com/topic/232195-need-some-help-from-the-prosplease/#findComment-1194532 Share on other sites More sharing options...
betterphp Posted March 30, 2011 Share Posted March 30, 2011 double post with http://www.phpfreaks.com/forums/index.php?topic=328883.0 Link to comment https://forums.phpfreaks.com/topic/232195-need-some-help-from-the-prosplease/#findComment-1194536 Share on other sites More sharing options...
Maq Posted March 30, 2011 Share Posted March 30, 2011 double post with http://www.phpfreaks.com/forums/index.php?topic=328883.0 Yes. @stackumhi - Do not post more than once. You actually triple posted the same exact question. I merged the replies from the other thread here. Link to comment https://forums.phpfreaks.com/topic/232195-need-some-help-from-the-prosplease/#findComment-1194539 Share on other sites More sharing options...
stackumhi Posted March 30, 2011 Author Share Posted March 30, 2011 Sorry for over posting and posting in the wrong location. Thank you for your help. Link to comment https://forums.phpfreaks.com/topic/232195-need-some-help-from-the-prosplease/#findComment-1194684 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.