2015-04-05 123 views
-1

無論是產品表和產品形象表我已經使用這個刪除的連接查詢

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
DELETE p, pm 
FROM product p 
LEFT JOIN productimage pm ON p.p_id = pm.p_id 
WHERE p.p_id = 1 
+0

地段....因爲搜索2個小時 – 2015-04-05 15:11:04