Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Get Matching and Non-matching rows

$
0
0

I want to be able to join 2 tables on a common column but get both those that match and those that do not match. For example use the following 2 select statements.

SELECT RepairOrderID, Customer FROM Repairs WHERE ROCloseDate BETWEEN '05-01-2014' AND '05-31-2014'

SELECT RepairOrderID, Customer FROM Invoices WHERE InvoiceDate -2014'

Assume the Repairs table returns RepairOrderID of 1, 2, 4, 5, 7 and Invoices table returns 1, 2, 3, 5, 6

I want to get back the RepairOrderID (1-7) and customer names as one joined table with NULLs where RepairOrderID's do not match.

How can I do this?


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>