March 13, 2009 at 4:57 pm
I have two tables (A) & (B) with a common field (Article_ID) between them. The number of records in table (A) is greater than the number of records in table (B). I want to be able to compare the two tables on (Article_ID) and then update table (B) with the missing reords. Thanks in advance for your help.
March 13, 2009 at 7:22 pm
I know that the following will do the comparison, but I'm not sure about the update in the same code.
Select FilePath
From tblArticles
Where NOT EXISTS (Select URL
From rating_urls
Where tblArticles.filepath = rating_urls.url
)
March 14, 2009 at 4:44 am
Doesn't you mean to INSERT new records from TableA to TableB than to UPDATE? If not the latter case, then you have to do something like this.
INSERT INTO TableB
SELECT *
FROM TableA A
WHERE NOT EXISTS(SELECT * FROM TableB WHERE Article_ID = A.Article_ID)
If latter is the case, then can you let us know how to UPDATE TableB with TableA WHEN there are no records available in TableA?
--Ramesh
March 14, 2009 at 7:19 am
Ramesh (3/14/2009)
Doesn't you mean to INSERT new records from TableA to TableB than to UPDATE? If not the latter case, then you have to do something like this.INSERT INTO TableB
SELECT *
FROM TableA A
WHERE NOT EXISTS(SELECT * FROM TableB WHERE Article_ID = A.Article_ID)
If latter is the case, then can you let us know how to UPDATE TableB with TableA WHEN there are no records available in TableA?
This is exactly what I was looking for, thanks very much.
March 14, 2009 at 7:29 am
I'm glad, I could help you.
--Ramesh
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply