这个需要分情况。
1,你的数据库表中有主键,且主键上面的数据为唯一值。也就是没有重复值。
那么你在删除的时候,将这个唯一值作为条件进行删除。
如:
delete
from
[表名]
where
id=1
2.所有的数据相同,那么你只能打开数据表,手工选定其中某一条,进行删除。
这条语句写的太乱了吧.....
delete
from
customers_basket
where
id=(select
cb.id
from
orders
o,orders_products
op,customers_basket
cb
where
o.orders_status=4
and
op.orders_id
=
o.orders_id
and
op.products_id
=
cb.products_id
and
cb.customers_id
=
o.customers_id);
试一下
列出要保留的记录ID,可以把这个结果写到一个临时表t1中:
SELECT
MAX(id)
AS
max_id
FROM
pedigree
GROUP
BY
number
然后:DELETE
FROM
pedigree
WHERE
id
NOT
IN
(SELECT
id
FROM
t1)
也就是:delete
from
pedigree
where
id
not
in(select
*
from
pedigree
where
group
by
number)。
pedigree
where
id
not
in(select
max(id)
from
pedigree
where
group
by
number
having
count(id)
>
0)
查询结果是否符合删除要求!