Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL - How to change value in column?

I have a OpenCart store with more than 23000 products and I need to change one option (Requeres Shipping) for all of my products. I need to change that option in my database. I have a table n0v_product with with column shipping with value 0. I need to change shipping value to 1 for all products. How to update the value in the column with phpMyAdmin?

like image 472
Rumen Georgieff Avatar asked Nov 16 '17 10:11

Rumen Georgieff


2 Answers

Run this in a test database before running it on production but this should do the job.

UPDATE n0v_product 
SET shipping = '1' 
WHERE shipping = '0'
like image 145
Jack Avatar answered Oct 01 '22 17:10

Jack


You can use a UPDATE command to change all values on column shipping to 1 on n0v_product:

UPDATE `n0v_product` SET `shipping` = 1

If you only want to set the value if shipping is 0 you can use the following:

UPDATE `n0v_product` SET `shipping` = 1 WHERE `shipping` = 0

You should check the rows before UPDATE to make sure you really want to UPDATE these rows:

-- all rows of table n0v_product
SELECT `shipping`, * FROM `n0v_product`

-- only rows with shipping = 0
SELECT `shipping`, * FROM `n0v_product` WHERE `shipping` = 0
like image 39
Sebastian Brosch Avatar answered Oct 01 '22 17:10

Sebastian Brosch