Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MYSQL - Update an entire Column

Tags:

mysql

I wanted to ask if there is a way to update an entire column with the same value. I want to run '0' down a column or '1'. I can use a php loop to do it but it will involve multiple DB calls etc.

Hopeing for a SQL statement that can run the same value down an entire mysql column.

cheers

like image 453
Adam Avatar asked Aug 14 '11 11:08

Adam


2 Answers

Something a simple as UPDATE table1 SET column1=1; should do it.

like image 64
ChrisW Avatar answered Oct 03 '22 19:10

ChrisW


UPDATE table_name SET column_name = 0

this will set the column value to 0 for all records, if this it want you want.

like image 43
H6. Avatar answered Oct 03 '22 20:10

H6.