dessolator Posted January 17, 2008 Share Posted January 17, 2008 Hi, I have two tables in my database that I want to get data out of members and courses table but the mysql join statement is confusing me so much. The members table has the pupils faculty id in which links to the courses table, I want to retreive the actual description of the course not the id for each user. The members table looks like this: member_idforenamesurnameemailusernamefaculty_id The courses table looks like this: faculty_iddescription The statement i'm using is: $sql = "SELECT members.member_id, courses.description FROM members AS members.member_id INNER JOIN courses.description AS courses ON members.member_id = courses.member_id"; But i'm getting errors near the inner join part and I haven't got a clue why, the tutorials that I followed were quite confusing as there are so many types of join. I would really appreciate your help. Thanks, Ian Quote Link to comment https://forums.phpfreaks.com/topic/86526-solved-join-statement/ Share on other sites More sharing options...
dessolator Posted January 17, 2008 Author Share Posted January 17, 2008 Hi, I tried to edit it to post the following but it wouldn't let me so here it is: The statement i'm using is: SELECT members.member_id, courses.description FROM members AS members.member_id INNER JOIN courses.description AS courses ON members.member_id = courses.member_id; Using mysql 5.0 Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.member_id INNER JOIN courses.description AS courses ON members.member_id = cour' at line 2 Thanks, Ian Quote Link to comment https://forums.phpfreaks.com/topic/86526-solved-join-statement/#findComment-442111 Share on other sites More sharing options...
revraz Posted January 17, 2008 Share Posted January 17, 2008 SELECT members.member_id, courses.description FROM members JOIN courses ON (members.faculty_id=courses.faculty_id); Quote Link to comment https://forums.phpfreaks.com/topic/86526-solved-join-statement/#findComment-442116 Share on other sites More sharing options...
dessolator Posted January 17, 2008 Author Share Posted January 17, 2008 Thanks so much revraz much appreciated m8 Quote Link to comment https://forums.phpfreaks.com/topic/86526-solved-join-statement/#findComment-442118 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.