MySQL REMOVE FROM AS

I am trying to remove certain types of duplicates from a table that can be selected by this query:

SELECT * 
  FROM `articles` AS t1 
 WHERE EXISTS (
                SELECT `id` 
                  FROM articles AS t2 
                 WHERE t2.link = t1.link AND 
                       t2.id > t1.id
               );

      

So, I tried these two queries, but they also don't work:

DELETE FROM `articles` AS t1 
WHERE EXISTS (
              SELECT `id` FROM articles AS t2 
               WHERE t2.link = t1.link AND 
                     t2.id > t1.id
              );

      

&

DELETE FROM t1 USING `articles` AS t1 
WHERE EXISTS (
              SELECT `id` 
                FROM `articles` AS t2 
               WHERE t2.link = t1.link AND 
                     t2.id > t1.id
              );

      

both return a syntax error.

+3


source to share


2 answers


You can use multiple tables in your proposal from

:



DELETE t1
FROM   `articles` t1 , `articles` t2
WHERE  t2.link = t1.link AND t2.id > t1.id

      

+3


source


delete
from articles using articles,
    articles a1
where articles.id > a1.id
    and articles.link = a1.link

      



+2


source







All Articles