Syntax Error in SQL Abfrage

eugen

Neuer Benutzer
Beiträge
1
Moin,
habe vor etwas in meiner MySQL Datenbank zu löschen.


Code:

Code:
DELETE FROM products_attributes ,
products_content ,
products_description ,
products_graduated_prices ,
products_images ,
products_noticfications ,
products_to_categories ,
products_xsell ,
reviews WHERE products_id IN (
SELECT products.products_id
FROM products
WHERE products.products_model = 'U 1050'
);


Leider bekomme ich diese Fehlermeldung:

#1064 - 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 'WHERE `products_id` = in ( select products.products_id FROM `products` WHERE ' at line 9
 
Werbung:
Du musst die Löschanweisungen einzeln geben:

Code:
DECLARE @model VARCHAR(10)
SET @model = 'U 1050'
 
DELETE FROM products_attributes
WHERE products_id IN (
SELECT products.products_id
FROM products
WHERE products.products_model = @model
);
DELETE FROM products_content
WHERE products_id IN (
SELECT products.products_id
FROM products
WHERE products.products_model = @model
);
...

Wenn du ein Scrpit brauchst um das öfter zu machen:
Code:
DECLARE @model VARCHAR(10)
SET @model = 'U 1050'
 
DELETE FROM products_attributes
WHERE products_id IN (
SELECT products.products_id
FROM products
WHERE products.products_model = @model
);
DELETE FROM products_content
WHERE products_id IN (
SELECT products.products_id
FROM products
WHERE products.products_model = @model
);
...
 
Zurück
Oben