Search
 
SCRIPT & CODE EXAMPLE
 

SQL

mysql delete duplicate rows but keep one

DELETE c1 FROM contacts c1
INNER JOIN contacts c2 
WHERE
    c1.id > c2.id AND 
    c1.email = c2.email;
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

how to delete all duplicate items in mysql

DELETE FROM FriendsData WHERE fID 
       NOT IN ( SELECT fID FROM FriendsData 
                   GROUP BY UserID, FriendsUserID, IsSpecial, CreatedBy)
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

identify rows with 2 same column value and delete duplicate mysql

DELETE c1 FROM contacts c1
INNER JOIN contacts c2 
WHERE
    c1.id > c2.id AND 
    c1.email = c2.email;
Code language: SQL (Structured Query Language) (sql)
Comment

PREVIOUS NEXT
Code Example
Sql :: union vs union all in sql 
Sql :: sql distinct 
Sql :: how to get max from each department in sql 
Sql :: postgres date 
Sql :: r write csv without index 
Sql :: multiple order by sql 
Sql :: mysql default uuid 
Sql :: how to open mysql in docker 
Sql :: case statement in select query in sql 
Sql :: nested query sql 
Sql :: sql insert into 
Sql :: how to recreate postgres database in docker 
Sql :: flask-sqlalchemy filter_by contains 
Sql :: update row postgres 
Sql :: like query 
Sql :: min mysql 
Sql :: isnull in sqlite 
Sql :: sql drop all tables 
Sql :: first mysql 
Sql :: mysql date time string format for marshmellow field schema 
Sql :: how to select from mssql 
Sql :: copy data from one postgres container to another 
Sql :: logical operators in sql 
Sql :: collation in sql 
Sql :: mysql show column type 
Sql :: offset in postgresql example 
Sql :: index postgres 
Sql :: t sql cursor tr 
Sql :: mysql max connections exceeded max_connections_per_hour 
Sql :: how to put 0 or 000 depending IDCustomer length in sql server 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =