0

I'm using JDBC as my servlet and trying manipulate to my database.

id | color | description |    
1  | blue  | fasfsfafssf |
2  | red   | afsafasfasf |

how can I choose all rows where color=blue and change the description based on the id? for now, i have soemthing along the lines:

SELECT id, description FROM table WHERE color="blue"

String description = manipulate(resultset.getInt(id)) //resultset is from executing the    query

Now how do i update the description of the same row with description?

hopefully that made sense

EDIT: The problem is that the way that description changes will be based on the ID (therefore the manipulate method).

5
  • 1
    Change description based on the ID in what way? Commented Oct 17, 2013 at 23:00
  • We're going to possibly need some more information. First, what do you expect to get - this is a big one and will help a lot. Second, are you actually trying to manipulate (change) the data or just change the value when you select it but leave it intact in the database? Commented Oct 17, 2013 at 23:04
  • The problem is that the way that description changes will be based on the ID (therefore the manipulate method). Commented Oct 17, 2013 at 23:26
  • That doesn't tell me how it changes. What kind of change? Are you trying to do something like id - description or repeat the description... I'm asking what you expect the result to be. And if you expect the original data to remain intact. Those are two very big questions that will impact the answer. Commented Oct 18, 2013 at 2:14
  • Based how? How will you derive the description from the id? Please be specific so that someone can give you a solution. Commented Oct 18, 2013 at 3:04

1 Answer 1

1

You don't need to use the id. Try this.

update table set description = 'fluffy' where color = 'blue';
Sign up to request clarification or add additional context in comments.

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.