What about George? He also is stored only in one table...-- prepare test datadeclare @TableA table (ID int, NAME varchar(10))insert @tableaselect 1, 'Tom' union allselect 2, 'George' union allselect 3, 'Richard'declare @TableB table (ID int, NAME varchar(10))insert @tablebselect 1, 'Tom' union allselect 3, 'Richard' union allselect 4, 'Kevin'-- find any single nameselect isnull(a.id, b.id) [id], isnull(a.name, b.name) [name]from @tablea afull join @tableb b on b.name = a.namewhere a.id is null or b.id is null-- find any single nameselect id, [name]from ( select id, name from @tablea union all select id, name from @tableb ) qgroup by id, [name]having count(*) = 1
Peter LarssonHelsingborg, Sweden