dannyp100 Posted April 12, 2013 Share Posted April 12, 2013 I am having trouble with SQL statements, i just can't seem to get them right This is the strcuture of the DB SRS_STUDENTstudentid varchar( 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_COURSEcoursecode varchar(14) latin1_swedish_ci coursetitle varchar(100) latin1_swedish_ci deptcode char(2) latin1_swedish_ciSRS_MODULEmodulecode 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!! Quote Link to comment Share on other sites More sharing options...
awjudd Posted April 12, 2013 Share Posted April 12, 2013 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 Quote Link to comment 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.