I am using the following query to insert values into one field in table A.
insert into A (name) values (\'abc\') where A.id=B.code and B.dept=\'hr\' ;
You should rather use UPDATE, if you want to change the value of the field in records you select using the WHERE clause.
UPDATE
WHERE