Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 1969
Alex Hales
  • 0
Alex HalesTeacher
Asked: May 31, 20222022-05-31T09:28:09+00:00 2022-05-31T09:28:09+00:00

mysql – Using inner join as ALIASES with multiple tables

  • 0

[ad_1]

I have these tables below:

create table student(
    studentName      varchar (40) not null,
    studentRollNo    varchar (30) primary key, -- also acts as username
    studentPassword  varchar(30) NOT NULL,
    studentGender    varchar(7) default NULL
);
create table supervisors(
    supervisorID varchar(30) foreign key references Faculty(facultyID) unique,
    sWorkLoad int default null,
    CHECK (sWorkLoad<=6 and sWorkLoad>=0)
);
create table co_supervisors(
    co_supervisorID varchar(30) foreign key references Faculty(facultyID) unique,
    csWorkLoad int default null,
    CHECK (csWorkLoad<=6 and csWorkLoad>=0)
);
create table studentGroup(
    groupID int IDENTITY(1,1) primary key ,
    Member1rollNo varchar(30) foreign key references student(studentRollNo) default NULL, -- member 1
    Member2rollNo varchar(30) foreign key references student(studentRollNo) default NULL, -- member 2
    Member3rollNo varchar(30) foreign key references student(studentRollNo) default NULL, -- member 3
    supervID  varchar(30) foreign key references supervisors(supervisorID),
    co_supervID  varchar(30) foreign key references co_supervisors(co_supervisorID) default NULL,
    projectTitle varchar(100) not null,
    projectDetails varchar (500) default NULL
);
create table FYP1(
     groupID int foreign key references studentGroup(groupID),
);

I want to display student details who are registered in FYP1.
with their supervisors, co_supervisors,and project title.

But I I’m not able to do so,
What I have done so far is this.

select sg.Member1rollNo,S.studentName,Member2rollNo,S.studentName,sg.Member3rollNo,sg.supervID,sg.projectTitle
FROM student S
inner join studentGroup SG ON S.studentRollNo = SG.Member1rollNo

OR some random tries like this

--  Faculty.facultyName
SELECT FYP1.groupID, studentGroup.Member1rollNo,student.studentName as student1, studentGroup.Member2rollNo,student.studentName  as student2,studentGroup.projectTitle
FROM FYP1 as FYP1_Students
INNER JOIN studentGroup ON (studentGroup.groupID = FYP1_Students.groupID)
INNER JOIN supervisors  ON (studentGroup.supervID = supervisors.supervisorID)
INNER JOIN student      ON (student1.studentRollNo = studentGroup.Member1rollNo)
INNER JOIN student      ON (student.studentRollNo = studentGroup.Member2rollNo)

Output or first query is this (example):

'i19-0434'  'Sourav Malani' 'i19-0498'  'Sourav Malani' NULL    'urooj.ghani'   'Indoor Navigation'
'i19-0466'  'Aftab Ali' 'i19-0528'  'Aftab Ali' NULL    'urooj.ghani'   'AI based Physics exp.'

I want output to be like:

'i19-0434'  'Sourav Malani' 'i19-0498'  'Student2 Name' NULL    'urooj.ghani'   'Indoor Navigation'
'i19-0466'  'Aftab Ali' 'i19-0528'  '<student2Name>'    NULL    'urooj.ghani'   'AI based Physics exp.'

[ad_2]

  • 0 0 Answers
  • 9 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 4997 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 1084 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 1028 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.