on 2007 Apr 29 2:42 PM
Hi,all
I need to update only one row in my table,
which sql expression can I use?
For example,I do the following:
sqlString = "UPDATE PivotTitle SET type = CASE WHEN (type = 2) THEN 1 WHEN (type = 3) THEN 2 WHEN (type = 4) THEN 3 ELSE type END"
The problem is that I have one row of each type(1,2,3) and many rows of
type 4,but I need to update only one row of type 4 to row of type 3.
Regards,
Michael
Thanks for your replies
I solved my problem by myself.
Simply I added one more column to my table
with auto number and now I update only one row
of particular type by choosing the row with max(number).
Regards,
Michael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Michael,
Typically, "row" is restricted via defining primary key filter in query:
sqlString = "UPDATE PivotTitle SET type = CASE WHEN (type = 2) THEN 1 WHEN (type = 3) THEN 2 WHEN (type = 4) THEN 3 ELSE type END WHERE ID=?"
PreparedStatement pstmt = conn.prepareStatement(sqlString);
pstmt.setInt(1, 1234); // Key value is second parameter
pstmt.executeUpdate();
Valery Silaev
SaM Solutions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I think there is no specific sql expression for your requirement,
what you can do is make you selection for type4 more narrow, so that you will select the specific row and update that.
hope it helps
regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
11 | |
10 | |
10 | |
10 | |
9 | |
8 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.