Search
 
SCRIPT & CODE EXAMPLE
 

SQL

mysql remove duplicates

DELETE c1 FROM tablename c1
INNER JOIN tablename c2 
WHERE
    c1.id > c2.id AND 
    c1.unique_field = c2.unique_field;
Comment

mysql remove duplicates

DELETE t1 FROM subscriptions t1
INNER JOIN subscriptions t2 
WHERE 
    t1.id < t2.id AND 
    t1.user_id = t2.user_id AND t1.name = t2.name
Comment

mysql delete older duplicates

DELETE FROM CONTACTS
WHERE ID NOT IN
      (SELECT *
       FROM (SELECT max(ID)		
             FROM CONTACTS
             GROUP BY EMAIL) t);
 -- ⇓ Test it ⇓ (Fiddle source link)
Comment

delete all duplicate rows keep the latest except for one in mysql

DELETE 
FROM
  `tbl_job_title` 
WHERE id NOT IN 
  (SELECT 
    * 
  FROM
    (SELECT 
      MAX(id) 
    FROM
      `tbl_job_title` 
    GROUP BY NAME) tbl)
Comment

mysql delete older duplicates

 delete test
   from test
  inner join (
     select max(id) as lastId, email
       from test
      group by email
     having count(*) > 1) duplic on duplic.email = test.email
  where test.id < duplic.lastId;
Comment

Remove duplicate old value in mysql

DELETE `yellow_page_content`
   from `yellow_page_content`
  inner join (
     select max(`id`) as lastId, `code`
       from `yellow_page_content`
      group by `code`
     having count(*) > 1) duplic on duplic.code = yellow_page_content.code
  where yellow_page_content.id < duplic.lastId;
Comment

mysql delete duplicate rows except one

DELETE FROM NAMES
 WHERE id NOT IN (SELECT * 
                    FROM (SELECT MIN(n.id)
                            FROM NAMES n
                        GROUP BY n.name) x)
Comment

mysql remove duplicates

DELETE t1 FROM contacts t1
INNER JOIN contacts t2 
WHERE 
    t1.id < t2.id AND 
    t1.email = t2.email;Code language: SQL (Structured Query Language) (sql)
Comment

PREVIOUS NEXT
Code Example
Sql :: sql check if table exists 
Sql :: oracle drop type 
Sql :: How to check if a column exists in a SQL Server table? 
Sql :: how to update sql server version 
Sql :: how to put is null in where in clause 
Sql :: C# mysql data reader from two tables 
Sql :: sql limit to 5 results 
Sql :: how to get table id sequence postgres 
Sql :: delete record mysql 
Sql :: isnull in sqlite 
Sql :: get only one row in mysql 
Sql :: sql create cluster index 
Sql :: install mysql 
Sql :: hibernate show sql xml property 
Sql :: sql select like 
Sql :: sql foreign key constraint 
Sql :: sql delete duplicate rows but keep one 
Sql :: calculer pourcentage mysql 
Sql :: psql attribute cannot login 
Sql :: insert query in oracle 
Sql :: how to check current root password in mysql 
Sql :: last date for each user sql 
Sql :: create table if not exists 
Sql :: import mysql command line 
Sql :: cast as decimal postgresql 
Sql :: change column in mysql 
Sql :: mysql in clausule string array 
Sql :: set value to null postgres 
Sql :: ubuntu install mysql 5.7 
Sql :: disable database droping sql 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =