Updating Multiple Tables with single Update query
WITH cte 
AS ( UPDATE tableB 
     SET salaryb = tableA.salary % 1000 
     FROM tableA 
     WHERE tableB.empid = tableA.empid
     RETURNING *
   )
UPDATE tableA
SET salary = salary / 1000;