title: Delete, upon foreign key constraint update
body: <p>MySQL offers the following:</p>
  
  <pre><code>INSERT INTO table (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1;
  </code></pre>
  
  <p>Does MySQL offer something similar for DELETE which would attempt to delete and upon foreign key constraint, update the record in the table which was attempted to be deleted?</p>
  
  <p>For instance...</p>
  
  <pre><code>DELETE FROM table1 WHERE idtable1 = 123;
  IF(foreign key constraint) {  //pseudo code...
    UPDATE table1 SET deleted=1 WHERE idtable1 = 123;
  }
  
  CREATE TABLE IF NOT EXISTS table1 (
    idtable1 INT NOT NULL,
    data VARCHAR(45) NULL,
    deleted TINYINT NOT NULL DEFAULT 0,
    PRIMARY KEY (idtable1))
  ENGINE = InnoDB;
  
  CREATE TABLE IF NOT EXISTS table2 (
    idtable2 INT NOT NULL,
    table1_idtable1 INT NOT NULL,
    data VARCHAR(45) NULL,
    INDEX fk_table2_table1_idx (table1_idtable1 ASC),
    CONSTRAINT fk_table2_table1
      FOREIGN KEY (table1_idtable1)
      REFERENCES table1 (idtable1)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  </code></pre>