Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

MySQL Script


1 reply to this topic

#1 pafranklin

  • Community Member
  • 258 posts
  • Real Name:Paul Franklin
  • Gender:Male
  • Location:Gloucestershire, UK

Posted 26 January 2012, 06:48

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....!

#2 pafranklin

  • Community Member
  • 258 posts
  • Real Name:Paul Franklin
  • Gender:Male
  • Location:Gloucestershire, UK

Posted 26 January 2012, 09:23

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....!