Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

MySQL Script


pafranklin

Recommended Posts

Hi there,

 

I am trying to write a MySQL query to update a field in the products table for products only in a certain category. However with the products_id and categories_id only linked in the products to categories table, how can I do this?

 

So far I have the following:

 

UPDATE products SET products_availability_id = '5' where products_to_categories category_id = '22'

 

I am trying to update the field products_availability_id in the products table but only for products in category 22..........

 

Any help would be appreciated!

 

Paul

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

Link to comment
Share on other sites

Sorted, so in case it helps someone else the revised MySQL script looks as follows:

 

update products set products_availability_id = 5 where products_id in (select products_id from products_to_categories where categories_id = 22)

 

This will update the products in category 22 and set the product availability id to 5 for all of these.

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

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...