---
title: "How to set all values in a single column MySQL Query"  
description: "How to set all values in a single column MySQL Query"  
author: "Revati S Misra"  
published: 2023-07-27  
updated: 2023-07-28  
canonical: https://www.mindstick.com/forum/159327/how-to-set-all-values-in-a-single-column-mysql-query  
category: "mysql"  
tags: ["database", "mysql"]  
reading_time: 2 minutes  

---

# How to set all values in a single column MySQL Query

How to set all [values](https://www.mindstick.com/forum/327/sum-textbox-values) in a [single column](https://www.mindstick.com/forum/161178/how-to-delete-duplicate-rows-based-on-single-column-value-in-mssql) [MySQL](https://www.mindstick.com/articles/12156/what-is-mysql) [Query](https://www.mindstick.com/blog/202/sub-query-in-sqlserver)

## Replies

### Reply by Aryan Kumar

To set all values in a single [column](https://www.mindstick.com/forum/33860/how-to-calculate-column-summary-in-sql-server) in MySQL, you can use the `UPDATE` statement with the `SET` clause. The syntax is as follows:

SQL

```plaintext
UPDATE table_name
SET column_name = value
WHERE condition;
```

For example, the following SQL statement will set all values in the `price` column of the `products` table to 100:

SQL

```plaintext
UPDATE products
SET price = 100;
```

This will update all rows in the `products` table where the `price` column is not NULL.

Here is an example of how to set all values in a single column in a MySQL query:

SQL

```plaintext
CREATE TABLE products (
  id INT NOT NULL AUTO_INCREMENT,
  name VARCHAR(255) NOT NULL,
  price INT NOT NULL,
  PRIMARY KEY (id)
);

INSERT INTO products (name, price) VALUES
('Product 1', 100),
('Product 2', 200),
('Product 3', 300);

UPDATE products
SET price = 100;
```

This will update all rows in the `products` table where the `price` column is not NULL. The `price` column will be set to 100 for all rows.

Here are some additional things to keep in mind when using the `UPDATE` statement:

- The `WHERE` clause is optional. If you do not specify a `WHERE` clause, all rows in the table will be updated.
- You can use the `SET` clause to update multiple columns at once.
- You can use the `UPDATE` statement to update a subset of rows in a table by using the `WHERE` clause.


---

Original Source: https://www.mindstick.com/forum/159327/how-to-set-all-values-in-a-single-column-mysql-query

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
