Inner Join Tables But Select From One Table Only

Just prefix the * with the desired table name, like this:

select TableA.* into Result from TableA
inner join TableB
on (TableB.Comp2 = TableA.Comp)
where TableB.Comp2 <> TableA.Comp

I think you want this, though:

select  *
    from TableA a
    where
        not exists (select b.Comp2 from TableB b where a.Comp1 = b.Comp2)

That will find all records in A that don't exist in B.


You could also do a left join and then just return rows that do not match:

SELECT TableA.*
FROM TableA
    LEFT JOIN TableB
        ON TableA.Comp = TableB.Comp2
WHERE TableB.Comp IS NULL

You can restrict the columns return like this, but it is typically better to not user the *, but to name all of the columns.