mysql - Rows won't delete when using left join -
i've got 2 tables on mysql server (5.5.25). 1 table holding product information other table keeps information on stock levels products. i've not defined foreign keys far:
mysql> describe product; +---------------------+--------------+------+-----+---------+----------------+ | field | type | null | key | default | | +---------------------+--------------+------+-----+---------+----------------+ | id | int(11) | no | pri | null | auto_increment | | product_no | varchar(45) | yes | | null | | | product_group | int(11) | no | | null | | +---------------------+--------------+------+-----+---------+----------------+ mysql> describe product_stock; +--------------+---------+------+-----+---------+----------------+ | field | type | null | key | default | | +--------------+---------+------+-----+---------+----------------+ | id | int(11) | no | pri | null | auto_increment | | product_id | int(11) | no | | null | | | amnt_stocked | int(11) | no | | null | | +--------------+---------+------+-----+---------+----------------+ now job delete product_stock entries member of product_group 2. syntax is:
delete ps product_stock ps left join product p on ps.product_id = p.id p.product_group = 2; the problem is: mysql won't delete row. because of performance problems might occur don't want use subquery. found many examples of left joins combined delete statements , don't what's going wrong here....
delete product_stock product_stock inner join product on product_stock.product_id = product.id product.product_group = 2;
Comments
Post a Comment