The code is as follows |
Copy Code |
Select A.* From temp a INNER join (select Name,sex to Temp GROUP by Name,sex has count (*) >1) b On a.name = b.name and a.sex = B.sex |
To see a delete duplicate record instance
User table structure
CREATE TABLE User (
varchar (uname) notnull;
varchar (upass);
);
The code is as follows |
Copy Code |
Create a temporary table and copy the data that is not duplicated in the user table CREATE TABLE user_tmp as SELECT DISTINCT * from user;
drop table user;//Delete user table Alert User_tmp Rename user;//renames the User_tmp table to user |
Another way
The code is as follows |
Copy Code |
Delete Ccs_users where UserID in ( Select MAX (userid) from Ccs_users GROUP by UserID has count (*) >1) |
Looks like a guy. SQL Delete duplicate record instance
code is as follows |
copy code |
Example: ID? Name?value 1?a?pp 2?a?pp 3?b?iii 4?b?pp 5?b?pp 6?c?pp 7?c?pp 8?C?III ID is primary key requirement You get the result Id?name?value 1?a?pp 3?b?iii 4?b?pp 6?c?pp 8?c?iii Method 1 Delete?yourtable? > where? [Id]?not?in? ( Select?max ([id])? from?yourtable? Group?by? (Name?+?value)) Method 2 Delete?a from table? A?left?join ( Select?id=min (ID)? From table? Group?by?name,value ) b?on?a.id=b.id Where?b.id?is?null |