Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving Data from two tables?

Status
Not open for further replies.

Vaastav

Programmer
Nov 6, 2002
5
GB
Hi, I've got a table with univeristy Modules with the following fields.

Stack
Module Code
Module Title
Credits
Status

Example data '1', 'INFO3420', 'Professional IT', '15', 'Mandatory'.

I also have a table with Course Details

CourseCode and CourseTitle
Example data 'CS', 'Computer Science'
Example data 'BIS', 'Business Information System'

Some of the modules overall lap courses for example a Business Student may be able to do the same Module as a Computer Science student. Only students on Computer Science should be able to select all the Modules for Computer Science and no other modules. How do I go about doing this.
 
You need to make the course details link to the course title , most easy method of this is to add an "id" column to each title, then you can select from modules and from details linking them by ID.

table.Courses

id
Stack
Module Code
Module Title
Credits
Status

example data '1','1', 'INFO3420', 'Professional IT', '15', 'Mandatory'.

table.Details
course_id
CourseCode
CourseTitle

'1','CS', 'Computer Science'

SELECT t.Stack,t.Module_Code,t.Module_Title,d.CourseCode,d.CourseTitle FROM table.Courses t, table.Details d where t.id= d.Course_id;

would return :
'1', 'INFO3420', 'Professional IT','CS','Computer Science'

Once you have succesfully linked the tables you would probably find it useful to add yet another table to do lookups as to which main courses can be selected under which course.
______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top