0

How to code such a simple SQL with Spring JDBC ?

UPDATE tableA SET column1 = var1 WHERE column1 IN (var2, var3, ...);

where var1 is dynamic variable and var2, var3, ... - dynamic variable list.

user2602807
  • 1,232
  • 2
  • 15
  • 28

1 Answers1

1

Without the IN , you can do like this:

PreparedStatement ps = connection.prepareStatement("UPDATE tableA SET column1 = ? WHERE column1 =? ");
ps.setString(1, var1);
ps.setString(2, var2);

And about how to deal with In I hope this may give you some clue.

After some search, I also found this question may help you:

PreparedStatement with list of parameters in a IN clause

How to set list of parameters on prepared statement?

PreparedStatement IN clause alternatives?

Community
  • 1
  • 1
shellbye
  • 4,620
  • 4
  • 32
  • 44