Jo Pletinckx
Jo Pletinckx

Reputation: 11

change content of a sql column to all the same

i have a column named (status) in table name oc_product

This column conects to my product to be 1= actif 0=inactif

now i want my column in my sql database to be all at 0 so al will be inactif so is thare a code to alter all the content in the column (status) so all in that column must be 0

thanks

Upvotes: 0

Views: 97

Answers (3)

Abhishek Sharma
Abhishek Sharma

Reputation: 6661

Use MySQL Update

UPDATE oc_product SET status = 0;

the UPDATE statement updates columns of existing rows in the named table with new values

Upvotes: 0

René Vogt
René Vogt

Reputation: 43886

UPDATE oc_product SET status = 0

That should do the trick. Since there is no WHERE clause, the status values of all records in oc_product will be set to 0.

EDIT: you may need to escape status like [status]. I'm not so used to mysql syntax details, so maybe status is a keyword and needs to be escaped.

Upvotes: 0

LDMJoe
LDMJoe

Reputation: 1589

UPDATE
     oc_product
SET
     status = 0
--it feels dirty not putting a WHERE clause here, but this is the answer

Upvotes: 1

Related Questions