I'm having trouble creating a Trigger that modifies more than one table.
DROP TRIGGER IF EXISTS vendedor_pago;
DELIMITER $$
CREATE TRIGGER vendedor_pago AFTER UPDATE ON parcelas
FOR EACH ROW
BEGIN
UPDATE vendas, comissao, parcelas
SET vendas.'conf_pagamento' = 1,
comissao.'pago' = IF(parcelas.'parcelas_pagas' = parcelas.'num_parcelas', 1, 0)
WHERE parcelas.'id_venda' = comissao.'id_venda'
AND comissao.'id_venda' = vendas.OLD.'id'
AND vendas.'id' = parcelas.'id_venda'
END$$
DELIMITER ;
I'm even not sure if the vendas.OLD.id
form is correct. The following error is returned when executing:
1064 - You have a syntax error in your SQL next to 'END' in the line 10
I would also like to know if the FOR EACH loop is really necessary, since I want to change only one record of each table.