删除重复的数据,只保留一条
delete from ecp_in_product_price_l where price_header_id = 229 and price_line_id not in
(select MAX(price_line_id) delId from ecp_in_product_price_l where price_header_id = 229 GROUP BY product_id )
如果这样写,,会报错误
[Err] 1093 - You can't specify target table 'ecp_in_product_price_l' for update in FROM clause
这时只需要通过将中间表,建select出来的结果 ,再select一次即可
delete from ecp_in_product_price_l where price_header_id = 229 and price_line_id not in (
select temp.delId from
(select MAX(price_line_id) delId from ecp_in_product_price_l where price_header_id = 229 GROUP BY product_id ) temp)