There is a table:

Create table Users (id_users INT not null PRIMARY KEY AUTO_INCREMENT, User_Name0 varchar(20) null, Name0 varchar(20) null, IP_Adress varchar(14) null); 

In order to remove duplicates I use:

 CREATE TABLE tmp SELECT * FROM users WHERE 1 GROUP BY User_Name0, Name0, IP_Adress; 

It turns out:

 id \User_name0 \ Name0 \ IP_adress 499 \Belka \Belka \ 333 280 \Potap \Potap \ 222 1 \Real \Real \ 111 

How to do:

 id \User_name0 \ Name0 \ IP_adress 3 \Belka \Belka \ 333 2 \Potap \Potap \ 222 1 \Real \Real \ 111 
  • what is your DBMS? In general, you do not create a tmp table with a sample query, but create a separate one; make the id field auto-increment, as in the main one, and then insert all the fields into it except for i.e. insert into tmp(user_name, name,ip) select user_name,name,ip ... he will use the new id himself and assign them in a row. Or use in the query variables for numbering, something like here. Stackoverflow.com/questions/484491 - Mike
  • MySQL 5.7. - Fedor

0