Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2006
    Posts
    133
    Plugin Contributions
    0

    help question How do I use SQL to update many categories_id values in products_to_categories?

    Within the products_to_categories table, I need to change too many categories_id values from 25 to 26. It would be easy if ALL 25s were to be changed but only some of them need to be changed. I thought I had done this before because I have in my "working mysql scripts" folder the following snippet of code:

    [FONT="Courier New"]UPDATE `zen_products_to_categories` SET `categories_id` = '26' WHERE (products_id, categories_id) = '434', '25';
    UPDATE `zen_products_to_categories` SET `categories_id` = '26' WHERE (products_id, categories_id) = '435', '25';
    UPDATE `zen_products_to_categories` SET `categories_id` = '26' WHERE (products_id, categories_id) = '439', '25';[/FONT]

    Unfortunately, I am getting the following SQL error message:

    [FONT="Courier New"]Error

    SQL query:

    UPDATE `zen_products_to_categories` SET `categories_id` = '26' WHERE (
    products_id,
    categories_id
    ) = '434',
    '25';

    MySQL said: Documentation
    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' '25'' at line 1 [/FONT]

    What is the proper SQL code (MySQL version is "5.0.81-community")? Do I need to include database/table names in some manner and if so, how do I do that again?

    Thank you!

  2. #2
    Join Date
    Aug 2006
    Posts
    133
    Plugin Contributions
    0

    Default Re: How do I use SQL to update many categories_id values in products_to_categories?

    Yargh. Duh. Durr. Had I simply used PhpMyAdmin to edit a couple of these, I could have learned the proper syntax earlier. Here is the answer to my above question:

    [FONT="Courier New"]UPDATE `zendb_zen`.`zen_products_to_categories` SET `categories_id` = '26' WHERE `live_products_to_categories`.`products_id` =434 AND `live_products_to_categories`.`categories_id` =25 LIMIT 1 ;

    UPDATE `zendb_zen`.`zen_products_to_categories` SET `categories_id` = '26' WHERE `live_products_to_categories`.`products_id` =435 AND `live_products_to_categories`.`categories_id` =25 LIMIT 1 ;

    UPDATE `zendb_zen`.`zen_products_to_categories` SET `categories_id` = '26' WHERE `live_products_to_categories`.`products_id` =439 AND `live_products_to_categories`.`categories_id` =25 LIMIT 1 ;
    [/FONT]

 

 

Similar Threads

  1. Blank products_to_categories
    By benn600 in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 27 Mar 2008, 08:39 PM
  2. Admin pages do not update values !!
    By pulkit in forum Customization from the Admin
    Replies: 4
    Last Post: 29 Sep 2007, 02:17 AM
  3. Reset products_id and categories_id
    By chansuresh in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 25 Jul 2006, 08:34 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •