Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Delete a Select Inner Join Query result

SELECT yturl from ytpointadder a
JOIN watched b on b.watchedyt = a.yturl AND b.ip = a.ip
Group by a.ip;

I want to delete the result of the query for exp this query result is :

yturl ip id
eY5WRONGXDI 197.XX.XX.XXX 1

Though i want to delete it from ytpointadder. I tried :

DELETE from ytpointadder a
JOIN watched b on b.watchedyt = a.yturl AND b.ip = a.ip
Group by a.ip;

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can’t specify same target table for update (delete) in FROM clause. So you have to use another outer query.

Try:

DELETE FROM ytpointadder
WHERE yturl IN  ( SELECT t.yturl FROM (SELECT a.yturl, a.ip from ytpointadder a
                                     JOIN watched b on b.watchedyt = a.yturl AND b.ip = a.ip
                                     Group by a.ip 
                                     ) as t 
                 ) ;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading