update query help

M

Me

I want to update table A with empid from table b. Tables a and b match with
first name and last name, I am getting operation error when I run the
following
query -

update a set empid = (select empid from b where a.firstname=b.firstname and
a.lastname=b.lastname)

I also tried -

update a set empid=b.empid
from a inner join b on (a.firstname=b.firstname and a.lastname=b.lastname)

Thank you in advance,
-Me
 
K

KARL DEWEY

Try this --
update a inner join b on (a.firstname=b.firstname) and
(a.lastname=b.lastname) set a.empid=b.empid;
 
M

Me

Karl,

Thank you, it worked.

-Me


KARL DEWEY said:
Try this --
update a inner join b on (a.firstname=b.firstname) and
(a.lastname=b.lastname) set a.empid=b.empid;
 

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