1

Assuming I have such table

|---------------------|------------------|
|          ID         |       Name       |
|---------------------|------------------|
|          1          |         x        |
|---------------------|------------------|
|          ..         |         x        |
|---------------------|------------------|
|          N          |         x        |
|---------------------|------------------|

I need to change name fields to "z" for IDs between 30 and 100. Is there any way to use a loop or a while condition instead of doing this:

UPDATE table
SET Name = 'z'
WHERE ID = 30
OR ID = 31
OR ID = 32
...

2 Answers 2

3

Simply specify that in the where clause

WHERE ID >= 30 AND ID <= 100
Sign up to request clarification or add additional context in comments.

Comments

3

You could use BETWEEN here:

UPDATE yourTable
SET Name = 'z'
WHERE ID BETWEEN 30 AND 100;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.