2

I have the following statement below that is getting an error of You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'c JOIN campaignsFroms f ON f.id = c.id JOIN campaignsRaw r ON r.' at line 2

What syntax am I missing?

Code:

DELETE 
    FROM campaigns c
    JOIN campaignsFroms f      ON f.id = c.id
    JOIN campaignsRaw r        ON r.id = c.id
    JOIN campaignsSubjects s   ON s.id = c.id
    JOIN campaignIPTracking ip ON ip.id = c.id
    JOIN campaignTracking ct   ON ct.id = c.id
    WHERE c.id = '1582'
Jess McKenzie
  • 8,345
  • 27
  • 100
  • 170
  • Have you tried just retyping `c JOIN campaignsFroms f ON f.id = c.id JOIN campaignsRaw r ON r.` ? – Justinas Oct 27 '15 at 06:01
  • 2
    http://stackoverflow.com/questions/652770/delete-with-join-in-mysql – Sougata Bose Oct 27 '15 at 06:03
  • 1
    Excerpt from the other question: a) You cannot use an alias for the main table (so the alias `c` has to be removed). b) You must specify which table you are deleting from in a multi-table delete, so the statement should start with `DELETE campaigns FROM campaigns`. – GolezTrol Oct 27 '15 at 06:07

1 Answers1

4
 DELETE c
FROM campaigns c
JOIN campaignsFroms f      ON f.id = c.id
JOIN campaignsRaw r        ON r.id = c.id
JOIN campaignsSubjects s   ON s.id = c.id
JOIN campaignIPTracking ip ON ip.id = c.id
JOIN campaignTracking ct   ON ct.id = c.id
WHERE c.id = '1582'                                 
Kushal Vora
  • 342
  • 2
  • 16
Kaushik Maheta
  • 1,741
  • 1
  • 18
  • 27