我正在尝试将concat
与Derby数据库查询一起使用。但我得到语法错误。如何在Derby中使用concat
?
以下代码仅供搜索
public ArrayList <Tablearray>ListUsers(String ValToSearch){
ArrayList <Tablearray> usersList = new ArrayList <Tablearray>();
Statement st;
ResultSet rs;
try {
Connection con = getConnection();
st = con.createStatement();
String searchQuery = "SELECT * FROM ABYP WHERE CONCAT(Id_Search, Tyl, Apothkh, Parathrhseis,Ti) LIKE '%"+ValToSearch+"%'";
//String searchQuery = "SELECT * FROM ABYP WHERE ||CONCAT|| (Id_Search) LIKE '%||"+ValToSearch+"||%'";
//String searchQuery = "SELECT *FROM ABYP where ID_SEARCH =? ";
rs = st.executeQuery(searchQuery);
Tablearray tablearray;
while (rs.next()){
tablearray = new Tablearray (
rs.getString("Id_Search"),
rs.getString("Tyl"),
rs.getString("Apothkh"),
rs.getString("Parathrhseis"),
rs.getString("Ti")
);
usersList.add(tablearray);
}
}catch(Exception ex){
System.out.println(ex.getMessage());
}
return usersList;
}