SELECT * FROM Student_1 S1 WHERE NOT EXISTS (SELECT * FROM Student_2 S2 WHERE S1.name = S2.name AND S1.age = S2.age AND S1.score = S2.score ) UNION ALL SELECT * FROM STUDENT_2 S2 WHERE NOT EXISTS (SELECT * FROM STUDENT_1 S1 WHERE S1.name = S2.name AND S1.age = S2.age AND S1.score = S2.score );
方法二 -- MINUS
复制代码 代码如下:www.VeVb.com
(SELECT * FROM Student_1 MINUS SELECT * FROM Student_2) UNION ALL (SELECT * FROM Student_2 MINUS SELECT * FROM Student_1)
方法三 -- HAVING GROUP BY
复制代码 代码如下:www.VeVb.com
SELECT DISTINCT name, age, score FROM ( SELECT * FROM Student_1 UNION ALL SELECT * FROM Student_2 )GROUP BY name, age, score HAVING COUNT(*)=1 ;