I have a query where I'm doing a self join on TableA on 'Id1' and 'Id2'. I then do an inner join on TableB. The table with the self join as 2 keys (Id1,Id2). I'm trying to get the records that do not match up with the Id in Table3. Is it a condition that I need to add on the join? Thanks!

```
SELECT *
FROM TableA t1
JOIN TableA t2 ON t1.Id1 = t2.Id2
JOIN TableB t3 ON t1.Id1 = t3.Id

```

EDIT :

```
SELECT *
FROM UCDetails ucd1
JOIN MS et ON ucd1.UKey = TRY_CAST(et.SubKey AS bigint)
JOIN dbo.UCDetails ucd2 ON ucd1.UKey = ucd2.ETTSubkey 
WHERE ucd1.ETTSubkey IS NULL

```

Sorry, I should of been more specific, so here is the query. What I want is to take only the record from ucd1 or ucd2 where if the ucd1 ETTSubkey IS NULL and the 'UKey' DOES NOT match the 'et.Subkey'. I can pull the records with this join but I only want to take the 'UCD' record where there isn't a match with the 'Subkey' on the et table.