Mysql資料庫中多條重複資料,如何只刪除一條

時間 2021-10-14 22:25:42

1樓:蒯淑蘭費琬

這個需要分情況。

1,你的資料庫表中有主鍵,且主鍵上面的資料為唯一值。也就是沒有重複值。

那麼你在刪除的時候,將這個唯一值作為條件進行刪除。

如:delete

from

[表名]

where

id=1

2.所有的資料相同,那麼你只能開啟資料表,手工選定其中某一條,進行刪除。

2樓:初懷雨步申

這條語句寫的太亂了吧.....

delete

from

customers_basket

where

id=(select

cb.id

from

orders

o,orders_products

op,customers_basket

cbwhere

o.orders_status=4

andop.orders_id

=o.orders_id

andop.products_id

=cb.products_id

andcb.customers_id

=o.customers_id);試一下

在mysql資料庫中如何讓某個欄位有重複的只取一條

3樓:小小筱冉絲

-- 保留

bai相du

同zhia值的

dao最小

專屬id行

select *

from table_a a

where not exists (

select 1 from table_a bwhere b.a = a.a

and b.id < a.id)

4樓:

select top 1 id,name,age from 表 order by age desc按照年齡倒序抄排序,然後取第一條bai。考慮可能有多人年齡相

du同,如果都zhi需取出,可dao以這樣寫:select id,name,age from 表 where age=(select max(age) from 表)

如何改mysql資料庫資料庫密碼

文件類共創空間 修改mysql是需要有mysql裡的root許可權的,下面介紹幾種修改mysql資料庫密碼的方法 方法一使用phpmyadmin,這是最簡單的了,修改mysql庫的user表,不過別忘了使用password函式。方法二使用mysqladmin,這是前面宣告的一個特例。mysqladm...

myeclipse連線mysql資料庫中文亂碼問題

action是get還是post get的話好像頭部設定一下編碼方式就可以了 contenttype text html chartset gbk pageencoding gbk post的話在處理頁面寫上 request.setcharacterencoding gbk 實在不行就弄個filte...

C插入資料庫,不能重複,怎麼防止資料庫中插入重複資料?

protected void submit click object sender,eventargs e 使用try 未出錯時執行的語句 catch exception ex 出錯是執行的語句finally 無論出錯與不出錯始終執行的語句用這個方法找找看是什麼問題,如果不好用最好把這段 抽成方法再...