title: How to delete two linked rows from MySQL database?
body: <p>Can somebody show my how to delete two linked rows?</p>
  
  <p>I use Delphi 2007 and MySQL.</p>
  
  <p>I have a database with two tables:</p>
  
  <pre><code>CREATE TABLE `Picture`.`Picture` (
    `ID` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
    `IMG` LONGBLOB,
    PRIMARY KEY (`ID`)
  )
  ENGINE = InnoDB;
  
  CREATE TABLE `contacts` (
    `ID` int(10) unsigned NOT NULL auto_increment,
    `FirstName` varchar(45) NOT NULL,
    `LastName` varchar(45) NOT NULL,
    `Phone` varchar(45) default NULL,
    `PICID` int(10) unsigned default NULL,
    PRIMARY KEY  (`ID`),
    KEY `FK_contacts_1` (`PICID`),
    CONSTRAINT `FK_contacts_1` FOREIGN KEY (`PICID`) REFERENCES `picture` (`ID`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 
  </code></pre>
  
  <p>In my Delphi Application I have <kbd>Delete</kbd> button. When I find some contact on my DBGrid and press <kbd>Delete</kbd> button I can delete only contact from table <code>contacts</code>, I also want to delete contact picture.</p>
  
  <p>I want to delete row from table <code>contacts</code> and row from table <code>Picture</code>. Table <code>Picture</code> is linked to table <code>contacts</code> with <code>foreign key</code>.</p>