Firstly you can find duplicate rows and find count of rows is used how many times and order it by number like this;
SELECT q.id,q.name,q.password,q.NID,(select count(*) from UserInfo k where k.NID= q.NID) as Count,_x000D_
(_x000D_
CASE q.NID_x000D_
WHEN @curCode THEN_x000D_
@curRow := @curRow + 1_x000D_
ELSE_x000D_
@curRow := 1_x000D_
AND @curCode := q.NID_x000D_
END_x000D_
) AS No_x000D_
FROM UserInfo q,_x000D_
(_x000D_
SELECT_x000D_
@curRow := 1,_x000D_
@curCode := ''_x000D_
) rt_x000D_
WHERE q.NID IN_x000D_
(_x000D_
SELECT NID_x000D_
FROM UserInfo_x000D_
GROUP BY NID_x000D_
HAVING COUNT(*) > 1_x000D_
)
_x000D_
after that create a table and insert result to it.
create table CopyTable _x000D_
SELECT q.id,q.name,q.password,q.NID,(select count(*) from UserInfo k where k.NID= q.NID) as Count,_x000D_
(_x000D_
CASE q.NID_x000D_
WHEN @curCode THEN_x000D_
@curRow := @curRow + 1_x000D_
ELSE_x000D_
@curRow := 1_x000D_
AND @curCode := q.NID_x000D_
END_x000D_
) AS No_x000D_
FROM UserInfo q,_x000D_
(_x000D_
SELECT_x000D_
@curRow := 1,_x000D_
@curCode := ''_x000D_
) rt_x000D_
WHERE q.NID IN_x000D_
(_x000D_
SELECT NID_x000D_
FROM UserInfo_x000D_
GROUP BY NID_x000D_
HAVING COUNT(*) > 1_x000D_
)
_x000D_
Finally, delete dublicate rows.No is start 0. Except fist number of each group delete all dublicate rows.
delete from CopyTable where No!= 0;
_x000D_