我用过这个
DELETE p.* , pm.* FROM product p , productimage pm
WHERE p.p_id = '1' and pm.p_id = '1';
但没有结果
CREATE TABLE IF NOT EXISTS `product` (
`p_id` int(10) NOT NULL AUTO_INCREMENT,
`p_names` varchar(50) NOT NULL,
`p_price` int(10) NOT NULL,
`p_description` varchar(100) NOT NULL,
PRIMARY KEY (`p_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
CREATE TABLE IF NOT EXISTS `productimage` (
`pimage_id` int(10) NOT NULL AUTO_INCREMENT,
`img` varchar(100) NOT NULL,
`p_id` int(10) NOT NULL,----------------------------foreign Key
PRIMARY KEY (`pimage_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5
答案 0 :(得分:0)
DELETE p, pm
FROM product p
LEFT JOIN productimage pm ON p.p_id = pm.p_id
WHERE p.p_id = 1