title: how to solve error:1365 division by 0 in mysql
body: <p>I want to generate insert to table from query but this query might throw a division by zero error:</p>
  
  <pre><code>insert into rpp
  select IFNULL(IF((IF(((((((`s`.`smi` + `s`.`jmb`) + `s`.`ruah`) +
  `s`.`stg_jd`) + `s`.`jdw_pro`) / `p`.`rate`) &lt;= 2),
  ((`p`.`rate` * 4) - ((((`s`.`smi` + `s`.`jmb`) + `s`.`ruah`) 
  + `s`.`stg_jd`) + `s`.`jdw_pro`)),0) &gt; 0),
  (FLOOR((IF(((((((`s`.`smi` + `s`.`jmb`) + `s`.`ruah`) 
  + `s`.`stg_jd`) + `s`.`jdw_pro`) / `p`.`rate`) &lt;= 2),
  ((`p`.`rate` * 4) - ((((`s`.`smi` + `s`.`jmb`) + 
  `s`.`ruah`) + `s`.`stg_jd`) + `s`.`jdw_pro`)),
  0) / `p`.`bets`)) * `p`.`bets`),0),0) AS `rp`
  FROM (`produk` `p`LEFT JOIN `stok` `s` ON ((`p`.`kode` = `s`.`kode_produk`)))
  </code></pre>
  
  <p>Thanks in advance!</p>