Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / SQL query to set all products quantity to 1

SQL query to set all products quantity to 1

Locked

Views: 1,630

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
3 Dec 2009, 12:35 PM
#1
skynetslo avatar

skynetslo

New Zenner

Join Date:
Nov 2009
Posts:
7
Plugin Contributions:
0

SQL query to set all products quantity to 1

I've just entered hundreds of items withouth setting their stock. Sincer I want them to allways be in stock I need to set the quantity for each product to 1. Since it's much easier then doing it 1 by 1, how can I do this with sql command?

3 Dec 2009, 1:44 PM
#2
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: SQL query to set all products quantity to 1

skynetslo:

I've just entered hundreds of items withouth setting their stock. Sincer I want them to allways be in stock I need to set the quantity for each product to 1. Since it's much easier then doing it 1 by 1, how can I do this with sql command?

update zen_products set products_quantity = 1 WHERE 1 ;

You may need to change " zen_products" if your database uses a different prefix.

If SOME of your products already have quantities, a better command would be

update zen_products set products_quantity = 1 WHERE products_quantity = 0 ;

Cheers
Rod

3 Dec 2009, 2:29 PM
#3
skynetslo avatar

skynetslo

New Zenner

Join Date:
Nov 2009
Posts:
7
Plugin Contributions:
0

Re: SQL query to set all products quantity to 1

Thank you very much RodG!

3 Dec 2009, 3:21 PM
#4
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,708
Plugin Contributions:
56

Re: SQL query to set all products quantity to 1

But be sure to turn off Admin->Configuration->Stock->Subtract stock to false.