I try create a view with one table multi time here is my code but the result is wrong.Can you help me I cant see here wrong thing.
SELECT DISTINCT
O1.HomeWorkId, O2.FileInfo AS TeacherFileInfo,
O2.Answer AS TeacherAnswer, O1.Answer AS StudentAnswer,
O1.StudentId
FROM
HomeWorkAnswer AS O1
INNER JOIN
HomeWorkAnswer AS O2 ON O1.FileInfo = O2.FileInfo
WHERE
(O1.HomeWorkId > 0)
I save my teacher answer and student answer in this table.In my project I select two times for compare the answer.But I thing for performance it is not good and try create something like this.
SELF JOINon the same field.union. w3schools.com/sql/sql_union.asp What exactly do you want the output to be?HomeWorkAnswer? How can you tell which row is a teacher answer vs a student answer? That's what you need to fix in your join