Results 1 to 5 of 5
  1. #1
    Join Date
    May 2016
    Location
    Ohio
    Posts
    422
    Plugin Contributions
    0

    Default SQL for Quantity

    What is the SQL code to set all product quantity to 1?

    i know it's something like... UPDATE `products` SET `products_quantity` = '1'


    Thanks!

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,949
    Plugin Contributions
    96

    Default Re: SQL for Quantity

    Quote Originally Posted by jmberman View Post
    What is the SQL code to set all product quantity to 1?

    i know it's something like... UPDATE `products` SET `products_quantity` = '1'


    Thanks!
    The query you posted will work, in general, to set each and every product's price to 1.0000.

    For more strict versions of MySQL, since the products_quantity field is a numeric value (not a string), I'd suggest

    UPDATE products SET products_quantity = 1;

    No quotes around that 1. The query will work in the admin's Tools / Install SQL Patches regardless of the site's DB_PREFIX, but phpMyAdmin requires the DB_PREFIX value (e.g. 'zen_', if set in the site's configure.php files):

    UPDATE zen_products SET products_quantity = 1;

  3. #3
    Join Date
    May 2016
    Location
    Ohio
    Posts
    422
    Plugin Contributions
    0

    Default Re: SQL for Quantity

    Any idea why this isn't working?

    UPDATE products SET products_quantity = 1000; WHERE `products`.`master_categories_id` = 58;

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,949
    Plugin Contributions
    96

    Default Re: SQL for Quantity

    Quote Originally Posted by jmberman View Post
    Any idea why this isn't working?

    UPDATE products SET products_quantity = 1000; WHERE `products`.`master_categories_id` = 58;
    Because you've got a stray semi-colon

  5. #5
    Join Date
    May 2016
    Location
    Ohio
    Posts
    422
    Plugin Contributions
    0

    Default Re: SQL for Quantity

    Ooooooh right! thank you!

 

 

Similar Threads

  1. SQL to set quantity for specific category
    By jmberman in forum General Questions
    Replies: 2
    Last Post: 11 Aug 2025, 01:13 PM
  2. Replies: 7
    Last Post: 15 Feb 2023, 03:05 AM
  3. Replies: 1
    Last Post: 5 Aug 2015, 01:11 PM
  4. Replies: 7
    Last Post: 29 Jul 2011, 08:37 PM
  5. Setting products quantity by SQL
    By the_doomsayer in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 13 Jun 2009, 10:47 AM

Posting Permissions

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