Topic:   i have three tables students table Have Id as a primary key Name Enrollment ,course table have Id as a primary key, Title, Code and studentcourse table have Id as a primary key studentId as a forei
Mar 08, 2021 13:19 2 Replies 749 Views SAI

 i have three tables

students table Have

Id as a primary key

Name

Enrollment

,course table have

Id as a primary key,

Title,

Code

and studentcourse table have

Id as a primary key

studentId as a foreign key,

courseId as a foreign key,

i want to show all students recod which have courses

how i get these record from joining tables.

Prev Next
Topic Replies (2)
  1. 1
    idnkx user

    PARTH

    select *
    from
    students s
    inner join
    studentcourse sc
    on s.Id = sc.studentId
    inner join
    course c
    on sc.courseId = c.Id

    1
    idnkx user

    TEJA

    For best practice use a 'middle' table to avoid M to M relation between two tables.
    should put 2 join statements and it should be INNER JOIN

Leave a Reply
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect