You cannot execute SELECT statements from a trigger. If you want to set variables, use SELECT INTO , for example. -
DECLARE supplierid_ INT(11); DECLARE customerid_ INT(11); SELECT supplierid, customerid INTO supplierid_, customerid_ FROM iv_documents WHERE id = OLD.note_documentid; IF supplierid_ = OLD.note_companyid THEN ...
Also, rename variables; they must be different from field names.
source share