You only check whether records exists before the if condition. Also you need to check if the value is greater than 0.
So the complete code can be written like this without the if condition in PHP.
$this->db->query("UPDATE table2 SET tech_voc=
(select column1 from table where id=2 )/
(select column1 from table where id=1 )
WHERE id=2 AND exists (SELECT column1 from table where id=1 and column1 >0 );");}