backpacker Posted March 30, 2010 Share Posted March 30, 2010 Hi, I have been googleing and searching but didn't find any solution to this problem. How can I add weight to all products in category? For example Category X's all products weight 4 kilograms, but there are hundreds of products in the category, so there must be an easier way than just adding the weight one at a time. SQL! I'm not very experienced with SQL and Oscommerce database is really new to me. I don't want to destroy all the tables by accident :blush: Could anyone help me with the (simple) sql query I need to add the weight Y.zz to all products in category X? update products WHERE category = 'X' set products_weight = '4.00' I know it goes something like that... Link to comment Share on other sites More sharing options...
Jan Zonjee Posted March 30, 2010 Share Posted March 30, 2010 Could anyone help me with the (simple) sql query I need to add the weight Y.zz to all products in category X? Since the categories_id for a product is stored in another table that particular query is not possible. Before you try this make sure you have a backup of your site: update products p, products_to_categories p2c set products_weight = 'Y.zz' where p.products_id = p2c.products_id and p2c.categories_id = 'X'; Link to comment Share on other sites More sharing options...
burt Posted March 30, 2010 Share Posted March 30, 2010 If Jans way does not work, you can try this; update products set products_weight = '4' where products_id in (select products_id from products_to_categories where categories_id = X) Link to comment Share on other sites More sharing options...
backpacker Posted March 31, 2010 Author Share Posted March 31, 2010 Since the categories_id for a product is stored in another table that particular query is not possible. Before you try this make sure you have a backup of your site: update products p, products_to_categories p2c set products_weight = 'Y.zz' where p.products_id = p2c.products_id and p2c.categories_id = 'X'; This worked great :) Thank you! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.