Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Writing a SQL Script to update weights


pafranklin

Recommended Posts

Posted

Hello,

 

I am just after some help please writing a MySQL script that will update and change the weights of products in a certain category. I am aiming to use this in phpMyAdmin to update the weights of lots of products in certain categories where they would be all the same weight.

 

For example to increase all products in category ID 21 to a weight of 2.75.

The second part of this is to increase products in category ID 21 where manufacturer ID is 16 to 2.75

 

Please can someone assist in getting me started?

 

Many thanks.

 

Paul

You will never learn if you don't try. And boy am I trying....!

Posted
Hello,

 

I am just after some help please writing a MySQL script that will update and change the weights of products in a certain category. I am aiming to use this in phpMyAdmin to update the weights of lots of products in certain categories where they would be all the same weight.

 

For example to increase all products in category ID 21 to a weight of 2.75.

The second part of this is to increase products in category ID 21 where manufacturer ID is 16 to 2.75

 

Please can someone assist in getting me started?

 

Many thanks.

 

Paul

 

I've got this far so far but still need a pointer or two please........

 

UPDATE 'Products' SET 'products_weight' ='2.75' WHERE 'products_categories'='21';

 

Not sure I have used the right names for product_categories??

 

Thanks again for any help.

You will never learn if you don't try. And boy am I trying....!

Posted
I've got this far so far but still need a pointer or two please........

If you have a reasonable new version of MySQL (4.1 or higher I believe) this should work:

update products set products_weight = '2.75' where products_id in (select products_id from products_to_categories where categories_id = 21)

Posted
If you have a reasonable new version of MySQL (4.1 or higher I believe) this should work:

update products set products_weight = '2.75' where products_id in (select products_id from products_to_categories where categories_id = 21)

Very many thanks. I will be giving this a try!

You will never learn if you don't try. And boy am I trying....!

Posted
Very many thanks. I will be giving this a try!

 

Just another thank you and to confirm that this cript does work and once you have identified the correct category ID (I did from the categories_description table) simply replace my 21 with your category ID and replace 2.75 with what ever weight you wish to use.

 

update products set products_weight = '2.75' where products_id in (select products_id from products_to_categories where categories_id = 21)

 

Very helpful.

 

Thank you again!

You will never learn if you don't try. And boy am I trying....!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...