Hello, I am trying to do the student evaluation and stuck in this problem.
Each student evaluates himself and all his friends in the same class. I have a sample table below. On the query, I tried to join the table to itself to get a new column calls "StudentID-Change" to list a student himself and his class mates. But I can't get the right result.
SELECT Table1.StudentID, Table1_1.StudentID, Table1.DepartmentID
FROM Table1 LEFT JOIN Table1 AS Table1_1 ON Table1.StudentID = Table1_1.StudentID;

ID StudentID ClassID
1 22 100
2 33 100
3 44 100

Here is the result I want to see in query.
StudentID StudentID-Change ClassID
22 22 100
22 33 100
22 44 100
33 22 100
33 33 100
33 44 100
44 22 100
44 33 100
44 44 100

Can anyone please help? What did I do wrong? Why can’t I get the right result using the that join?
Thanks very much.

Recommended Answers

All 3 Replies

It might help if we saw what was in the original table you are querying.
And that's not an inner join, it's just a join.

I added the database in zip file.

thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.