I need to do something like this
insert into tableA(code) select code from tableB where id=tableB.id;
I cant insert the code until both id are matched. How do i do this?
You can either do a join or use where exists like
insert into tableA(code)
select tb.code
from tableB tb
join tableA on tableA.id = tableB.id;
(OR)
insert into tableA(code)
select tb.code
from tableB tb where exists(select 1 from tableA
where id = tb.id);
Looking at your comment, looks like you rather need a UPDATE statement like
UPDATE tableA a
JOIN tableB b ON a.id = b.id
SET a.code = b.code;
where id, id field is field of tableA ?