alexa
Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry

SQL Server - Combine two select queries in sql ?

SQL Server - Combine two select queries in sql ?

You could also do it in a single query using a join if UNION doesn't count for "single query":

 SELECT s2.* 
  FROM Semester2 s2
       LEFT OUTER JOIN Semester1 s1
         ON s2.StudentId = s1.StudentId
         AND s2.SubjectId = s1.SubjectId
 WHERE s1.StudentId IS NULL; 

The WHERE clause will make it so only results where there isn't a perfect match in Semester1 appear.


20 0
7

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online