---
title: "SQL - Update multiple cells in one columns with the same ID"  
description: "SQL - Update multiple cells in one columns with the same ID"  
author: "Anonymous User"  
published: 2014-09-22  
updated: 2023-04-28  
canonical: https://www.mindstick.com/forum/2268/sql-update-multiple-cells-in-one-columns-with-the-same-id  
category: "database"  
tags: ["database"]  
reading_time: 2 minutes  

---

# SQL - Update multiple cells in one columns with the same ID

I have a [table](https://www.mindstick.com/articles/43918/how-to-design-table-using-bootstrap) **Answer** in [SQL Server](https://www.mindstick.com/articles/12999/what-is-table-valued-function-in-sql-server) like this:

## QuestionID AnswerID AnswerContent IsTrue

1 1 1990 True

1 2 300$ False

1 3 1992 True

2 4 1993 False

2 5 400$ True

2 6 600$ False

5 7 Lion False

5 8 Tiger True

5 9 Elephant False

Because the AnswerID is an [auto](https://www.mindstick.com/forum/33810/remote-view-in-android-auto-cancel-custom-notification)-[increment](https://www.mindstick.com/forum/173/auto-increment-id) and I don't know exactly its [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) when running the query.

So how can I [update](https://www.mindstick.com/forum/156353/what-is-hummingbird-update) the AnswerContent [column](https://www.mindstick.com/forum/33860/how-to-calculate-column-summary-in-sql-server)?

Example: I need to update

"Tiger - False" to "Elephant - True"

"Lion - True" to "1992 - False"

--- Update ---

I cannot change the table [structure](https://www.mindstick.com/articles/23258/choose-your-business-structure-wisely) because it's my [teacher](https://www.mindstick.com/blog/12733/5-great-things-about-joining-a-teacher-training-course-in-faridabad)'s order.

## Replies

### Reply by Aryan Kumar

To update multiple cells in one column with the same ID in SQL, you can use the UPDATE statement with a WHERE clause to specify the condition for the rows to be updated.

Here's an example of how to update multiple cells in a column with the same ID:

```php
UPDATE table_name
SET column_name = new_value
WHERE id = your_id;
```

In this example, **table_name** is the name of the table, **column_name** is the name of the column that you want to update, **new_value** is the value that you want to update the cells to, **id** is the name of the column that contains the ID values, and **your_id** is the ID value that you want to update.

For instance, let's say you have a table named **customers** with columns **id**, **name**, and **email**. If you want to update the email of all customers with the ID 5 to "[new_email@example.com](mailto:new_email@example.com)", you can use the following SQL statement:

```php
UPDATE customers
SET email = 'new_email@example.com'
WHERE id = 5;
```

This will update all rows in the **customers** table with the ID 5 and set their email to "[new_email@example.com](mailto:new_email@example.com)".

\

### Reply by Anchal Kesharwani

hi pravesh,

you need to try this:

You can do it in one shot using the CASE expression. Here is an example:

```
UPDATE MyTableSET    AnswerContent = CASE        WHEN AnswerContent='Tiger' AND IsTrue='False` THEN `Elephant`        ELSE AnswerContent ---- Keep the value unchanged    END,   IsTrue = ... -- Do other columns using the same expression structure
```


---

Original Source: https://www.mindstick.com/forum/2268/sql-update-multiple-cells-in-one-columns-with-the-same-id

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
