SQL query for distinct professors and courses

0 votes

There is a database on instructors, departments, courses, and timetables, so the question is stated accordingly. You must create a query that gives you a list of all the professors' names and the courses they teach. Each row must start with the professor's name and end with the name of the class the professor instructs. The rows must not contain any duplicates.

The table name and field names in the schema I have are:

PROFESSOR: ID, NAME, DEPARTMENT_ID, SALARY
DEPARTMENT: ID, NAME
COURSE: ID, NAME, DEPARTMENT_ID, CREDITS
SCHEDULE: PROFESSOR_ID, COURSE_ID, SEMESTER, YEAR

The code I have right now:

SELECT DISTINCT p.Name AND c.NAME
FROM Prodessor p, Course c, Schedule S

WHERE
    p.DEPARTMENT_ID = c.DEPARTMENT_ID
    AND
    p.ID = s.PROFESSOR_ID
    AND
    c.ID = c.COURSE_ID

The output is a list of all the professors, but there is just one course; there are no other courses. What exactly is wrong here? Additionally, it said that PROFESSOR.ID is not related to COURSE. p.ID = s because of PROFESSOR ID. valid PROFESSOR ID.

Can someone please help me with this?

Aug 26, 2022 in Database by Kithuzzz
• 38,000 points
22,214 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Database

0 votes
1 answer

How to schedule a job for SQL query to run daily?

down voteaccepted Expand the SQL Server Agent node ...READ MORE

answered Oct 25, 2018 in Database by Frankie
• 9,830 points
10,186 views
0 votes
1 answer

How to schedule a job for sql query to run daily?

Hii, To schedule a job for sql query ...READ MORE

answered May 4, 2020 in Database by Niroj
• 82,840 points
4,054 views
0 votes
0 answers

Request for SQL Query

Hi team, How can I get a distinct ...READ MORE

Jun 8, 2020 in Database by vnk
• 390 points
772 views
0 votes
1 answer

SQL Server replaces LEFT JOIN for LEFT OUTER JOIN in view query

You are getting the joins confused and ...READ MORE

answered Feb 4, 2022 in Database by Neha
• 9,020 points
1,481 views
0 votes
0 answers

How Stuff and 'For Xml Path' work in SQL Server?

Table is: Id Firstname 4 abc 4 def 4 ghi 4 jkl 4 mno Required output: Id Name 4 abc,def,ghi,jkl,mno Query: SELECT ID, ...READ MORE

Feb 23, 2022 in Database by Neha
• 9,020 points
5,978 views
0 votes
0 answers

ORA-01476: "divisor is equal to zero" for SQL query (Oracle 10g)

I'm creating a SQL query with Oracle ...READ MORE

Aug 25, 2022 in Database by Kithuzzz
• 38,000 points
722 views
0 votes
1 answer
0 votes
1 answer

How to change the default value and to alter a column in sql?

Hi, You can try this: ALTER TABLE foobar_data CHANGE ...READ MORE

answered Jun 24, 2019 in Big Data Hadoop by Gitika
• 65,770 points
1,518 views
0 votes
1 answer

What is an index in SQL?

An index is used to speed up ...READ MORE

answered Feb 3, 2022 in Database by Vaani
• 7,070 points
673 views
0 votes
1 answer

Ordering by the order of values in a SQL IN() clause

Use MySQL's FIELD() function: SELECT name, description, ... FROM ... WHERE id ...READ MORE

answered Feb 4, 2022 in Database by Neha
• 9,020 points
5,276 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP