Musa :
zip :
use where not exists for this:
This below gives the list to delete
select *
from product_image a
where exists
(
select 1 from product_image b
where a.product_id = b.product_id and a.id < b.id
)
This below delete all but the first for each product_id
delete
from product_image
where id in
(
select id from
(
select id
from product_image a
where exists
(
select 1 from product_image b
where a.product_id = b.product_id and a.id < b.id
)
)a
)
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=217383&siteId=1