match values, then update fields

J

jennifer

I need to match field values in 2 tables, then update
fields in table A with data from table B if there is a
match. If there is no match in table A - I need to add a
new record and fill it with info from table B.
 
S

SG

1. UPDATE A INNER JOIN B ON A.id = B.id SET A.f1 = .[f1], .... ;

2. INSERT INTO A ( id, f1,... ) SELECT B.id, B.f1, ...
FROM A RIGHT JOIN B ON A.id = B.id
WHERE A.id Is Null;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top