Forum Moderators: coopster
$query = "DELETE products
,join_cats_products
,join_manufacturers_products
FROM products
,join_cats_products
,join_manufacturers_products
WHERE products.prod_id=join_cats_products.prod_id
and products.prod_id=join_manufacturers_products.prod_id
and products.prod_id='20'
";
Would it be better to repeat the above query 3000 times or use the following
$query = "DELETE products
,join_cats_products
,join_manufacturers_products
FROM products
,join_cats_products
,join_manufacturers_products
WHERE products.prod_id=join_cats_products.prod_id
and products.prod_id=join_manufacturers_products.prod_id
and (products.prod_id='20' OR products.prod_id='20' etc. 3000 times)
";
Any other suggestions would be gratefully received.
Thanks
Ray...
but again I am not sure that I understood your examples.
<edit>more about it</edit>
if you do not use InnoDB engine I willl first ALTER concerned tables to InnoDB engine
and use transactions; one never know what could go wrong :)
AND `products`.`prod_id` IN ('20','25','26', [...] )
The only limit to how many items you can process at once using this method is only limited to the maximum size of a SQL query (measured in bytes, not characters, and you can find that by running
SHOW VARIABLES LIKE 'max_allowed_packet';).