Jump to content

Recommended Posts

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_id
forename
surname
email
username
faculty_id

 

The courses table looks like this:

faculty_id
description

 

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

Link to comment
https://forums.phpfreaks.com/topic/86526-solved-join-statement/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/86526-solved-join-statement/#findComment-442111
Share on other sites

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.