Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2008

    Question Unanswered: displaying data from multiple tables

    Hi there,

    As the title of this topic illustrates, i'm having trouble dumping relevant data from columns of different tables. Using isql*plus, I have three tables appropriatly related. A 'course' table, 'student' and 'next_of_kin' tables. I have many students enrolled on various courses but only a hanfull of courses offer the module option 'Database Systems'. I have no 'module' table but i know the three course names which provide the module option. I intend on producing a report hich lists all students enrolled on the courses which provid the module option 'Database Systems'. I have attempted the report but i keep getting a 'cartesian product' displaying all next_of_kin names instead of the appropriate. Also i am struggling to come up with the right WHERE statement to depict only the three courses which provide the module option 'Database Systems' as defined by 'courseNo' in both 'course' and 'student' tables.

    Here is the most recent attempt:

    --set echo off
    --set pagesize 24
    --set feedback off
    --set linesize 78

    col A format 99999999 heading 'Student No'
    col B format A15 heading 'Student Name'
    col C format A15 heading 'Course Name'
    col D format 99999999 'Course No'
    col E format A10 heading 'Next-of-Kin'
    break on A skip 1 on B

    TTitle 'Business Studies 1 Option BT300'
    BTitle 'Prepared By : Richard Stroud / 20527796'

    Select student.StudentNo "Student No",
    student.fName || ' ' || student.lName "Student Name",
    course.title "Course Name",
    course.courseNo "Course No",
    next_of_kin.fName || ' ' || next_of_kin.lName "Next-of-Kin"

    From student, course, next_of_kin
    where course.courseNo = '12885545'

    order by studentNo

    --clear columns
    --TTitle off
    --BTitle off
    --set feedback on
    --set pagesize 24
    --clear breaks

    Any help towards this toipic will be GREATLY appreciated

  2. #2
    Join Date
    Sep 2002
    Provided Answers: 1
    Looks like homework, so I'll give you a clue rather than a full answer

    If you just put 2 tables in the FROM clause you create a Cartesian Product, i.e. for each row of table A show each row of table B. To get onlt the related records you need a join condition: WHERE =

    The more modern syntax is FROM a JOIN b ON =

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts