Hello,
Can somebody show my how to delete two linked row using delphi.
I Use delphi 2007 and MySql.
In MySql i have database with two Table. Table Contacts(ID, FirstName, LastName, Phone, PICID) and table Picture(ID, IMG)
MySql Tables:
In my Delphi Application I have Delete Button. When I find some Contact on my DBGrid and press DELETE Button I can delete only contact from table Contact, I aslo want to delete contact picture.
I want to delete row from table CONTACTS and row from Table PICTURE. Table Picture Is linked to table Contact With foreign key.
Can somebody show my how to delete two linked row using delphi.
I Use delphi 2007 and MySql.
In MySql i have database with two Table. Table Contacts(ID, FirstName, LastName, Phone, PICID) and table Picture(ID, IMG)
MySql Tables:
Code:
CREATE TABLE `Picture`.`Picture` (
`ID` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`IMG` LONGBLOB,
PRIMARY KEY (`ID`)
)
ENGINE = InnoDB;
Code:
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;
In my Delphi Application I have Delete Button. When I find some Contact on my DBGrid and press DELETE Button I can delete only contact from table Contact, I aslo want to delete contact picture.
I want to delete row from table CONTACTS and row from Table PICTURE. Table Picture Is linked to table Contact With foreign key.