Jump to content

Help with mySQL queries!


dannyp100
 Share

Recommended Posts

I am having trouble with SQL statements, i just can't seem to get them right

This is the strcuture of the DB

 

SRS_STUDENT
studentid     varchar( 8)     latin1_swedish_ci                     
forename     varchar(60)     latin1_swedish_ci                  
surname     varchar(40)     latin1_swedish_ci                  
coursecode     varchar(14)     latin1_swedish_ci                      
stage         smallint(6)     No     0                                              
email         varchar(50)     latin1_swedish_ci     

SRS_COURSE
coursecode     varchar(14)     latin1_swedish_ci         
coursetitle     varchar(100)     latin1_swedish_ci         
deptcode     char(2)     latin1_swedish_ci

SRS_MODULE
modulecode     varchar(6)     latin1_swedish_ci         
moduletitle     varchar(120)     latin1_swedish_ci         
points         int(11)                 
level         char(2)     latin1_swedish_ci     
 

I am firstly trying to show students on a course
, i have got:

'select forename, surname, coursetitle, from srs_student
        inner join srs_course where coursecode = coursecode'

 

I am a beginner to sql, what seems to be the problem?

I am also trying to do the same thing but showing students on a module, what logic would help me do this?

Thankyou!!

 

Link to comment
Share on other sites

You are missing the definition of what you are actually joining your two tables on as well as you need to prefix your tables in your WHERE clause (which is actually defining your join predicate).

SELECT forename, surname, coursetitle
FROM srs_student AS s
INNER JOIN srs_course AS c ON s.coursecode = c.coursecode
Link to comment
Share on other sites

This thread is more than a year old.

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.

 Share

×
×
  • 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.