1
"SELECT * FROM PlayerClass WHERE Username = '" + p.getName() + "'"

So I have selected the specific row and how would I go about inserting a value in column ExColumn in the same exact row?

1
  • see for UPDATE syntax Commented Sep 14, 2013 at 13:00

3 Answers 3

2

If you're allowed to use JDBC and PreparedStatement, I would suggest you do this:

String sql = "UPDATE PlayerClass SET ExColumn = ? WHERE Username = ?";
PreparedStatement ps = connection.prepareStatement(sql);
ps.setObject(1, exColumnValue); // exColumnValue is the data you're trying to insert
ps.setString(2, p.getName());
ps.executeUpdate();

This way you'll be avoiding SQL injection attacks.

Sign up to request clarification or add additional context in comments.

Comments

1

You have to use UPDATE

"Update PlayerClass set Username = '" +someValue + "'"

That will update all rows

To update secific rows with some condition ,add where clause.

 "Update PlayerClass set Username = '" +someValue + "'
                                 WHERE Username = '" + p.getName() + "'"

1 Comment

You have a missing where clause!
1

May be your are trying to update specific row. then this will help you

UPDATE PlayerClass SET ExColumn='YOUR_INSERTION_DATA_IN_THIS'
WHERE Username = 'XYZ'

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.