Sunday, March 11, 2012

Compare Differences 2 Fields

I have an Id# as a PK in one table and I am trying to create a FK relationship on another table I need to compare the data because the new FK table has a few Id#'s that don't match up what is the best way to do this?-- this will list the ID in onetable but not in anothertable
select *
from onetable o left join anothertable a
on o.id = a.id
where a.id is null

do you have the other case ? ID in anothertable but not in onetable ?|||

Maybe something like:

select id#
from newTable a
where not exists
( select id#
from firstTable b
where a.id# = b.id#
)

No comments:

Post a Comment