title: How do I execute multiple querys inside an If inside a procedure?
body: <p>I am trying to execute two querys that &quot;transfer&quot; money from one bank to the other (one bank is one table), but only if the new balance is above 0. sc_bank and sub_bank are the two tables, amountOfMoney,  customerIDsc and customerIDsub are parameters in the procedure. What am I doing wrong that phpmyadmin gives me multiple SQL sintax errors?</p>
  <pre><code>BEGIN
      SELECT @A:=sub_bank.value FROM sub_bank WHERE customer_id = customerIDsub;
      IF @A - amountOfMoney &gt; 0 THEN 
          UPDATE sc_bank SET sc_bank.value = sc_bank.value + amountOfMoney WHERE sc_bank.customer_id = customerIDsc;
          UPDATE sub_bank SET sub_bank.value = sub_bank.value - amountOfMoney WHERE sub_bank.customer_id = customerIDsub;
      END IF
  
  END;
  </code></pre>
  <p>Edit:
  This is the function that phpmyadmin tries to execute to create the procedure, it seems like it puts the IF in the WHERE statement of the first update</p>
  <pre><code>CREATE DEFINER = `root`@`localhost` PROCEDURE `proceduro`(
      IN `amountOfMoney` DECIMAL(6, 2),
      IN `customerIDsc` INT(10),
      IN `customerIDsub` INT(10)
  ) NOT DETERMINISTIC NO SQL SQL SECURITY DEFINER
  BEGIN
      SELECT
          @A := sub_bank.value
      FROM
          sub_bank
      WHERE
          customer_id = customerIDsub; IF @A - amountOfMoney &gt; 0 THEN
      UPDATE
          sc_bank
      SET
          sc_bank.value = sc_bank.value + amountOfMoney
      WHERE
          sc_bank.customer_id = customerIDsc;
      UPDATE
          sub_bank
      SET
          sub_bank.value = sub_bank.value - amountOfMoney
      WHERE
          sub_bank.customer_id = customerIDsub;
  END IF
  END;
  </code></pre>