Comments - Trigger Overview

4 years, 6 months ago Jan Steinman

Okay, answering my own question: I should have known this, but the answer is to use a seperate "join table" that contains a pointer to both the originating record and the inserted record:

BEGIN
INSERT INTO general_journal SET
  -- other data as needed;
INSERT INTO `sales-general_journal` SET
  general_journal_ID = last_insert_id,
  sales_ID = NEW.ID;
END

Now, both records are available from either record by doing a LEFT JOIN on the `sales-general_journal` table.

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.