Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting all values in a MySQL field to 0

Tags:

php

mysql

I have the following Mysql 'test' table:

id -- number
1 -- 2
2 -- 33
3 -- 32
4 -- 162
5 -- 42
6 -- 142
7 -- 113
8 -- 12

What would be the query to turn all the values in field 'number' to 0?

I'm trying a kind of reset.

Thanks a ton!

like image 379
user712027 Avatar asked May 03 '11 15:05

user712027


People also ask

How do you set a column to 0 in SQL?

UPDATE [table] SET [column]=0 WHERE [column] IS NULL; Null Values can be replaced in SQL by using UPDATE, SET, and WHERE to search a column in a table for nulls and replace them. In the example above it replaces them with 0.

How do I change the value of a whole column in MySQL?

MySQL UPDATE command can be used to update multiple columns by specifying a comma separated list of column_name = new_value. Where column_name is the name of the column to be updated and new_value is the new value with which the column will be updated.

How do I restrict column values in MySQL?

MySQL CONSTRAINT is used to define rules to allow or restrict what values can be stored in columns. The purpose of inducing constraints is to enforce the integrity of a database. MySQL CONSTRAINTS are used to limit the type of data that can be inserted into a table.


Video Answer


1 Answers

Here:

UPDATE test SET number = 0;
like image 128
Gustav Larsson Avatar answered Oct 05 '22 22:10

Gustav Larsson