如何使用 where 和 concact 在查询中添加列?我尝试使用 Arraylist 但不正确
String search = searchField.getText();
ArrayList<String> check = new ArrayList<>();
if (CheckBoxCodice.isSelected()){
check.add("Codice");
}
if (CheckBoxRagioneSociale.isSelected()){
check.add("Ragione_Sociale");
}
if (CheckBoxComune.isSelected()){
check.add("comune");
}
UpdateTabella("select * from anagraficaclifor where concact (" + check +") like '%"+ search + "%'");
最佳答案
尝试使用 StringBuilder
StringBuilder builder = new StringBuilder()
builder.append( "yourstring" );
builder.append(",");
builder.append( "yourstring2" );
如果构建器准备就绪,您就可以使用
builder.toString()
这给了你
"yourstring,yourstring2"
编辑: 您只需添加
builder.append(",");
builder.append( "yourstring2" );
在每个 if 语句中并在最后使用
builder.deleteCharAt(0);
关于Java 使用 where 和 concat 在查询中添加列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35927627/