我正在尝试执行以下操作并且它不接受它。
String sql_eco = "select * from orders where EmployeeID=" +e_ID + " and CustomerID ="' + cu_ID + "'";
从两个表和两个值(变量)中选择
答案 0 :(得分:0)
尝试,假设CustomerID
和EmployeeID
都是Integer
列类型
String sql_eco = "select * from orders where EmployeeID=" +e_ID + " and CustomerID =" + cu_ID;
答案 1 :(得分:0)
试试这个:
String sql_eco = "select * +
from orders +
where EmployeeID=" +e_ID + " and CustomerID ='" + cu_ID + "'";
^
答案 2 :(得分:0)
使用它。你错放了“for CustomerId
String sql_eco = "select * from orders where EmployeeID=" +e_ID + " and CustomerID ='" + cu_ID + "'";
答案 3 :(得分:0)
值变量你想说这样的话吗?
String sql_eco = "select * +
from orders +
where 1=1 ";
if(e_ID != null) {
sql_eco += " AND EmployeeID=" +e_ID ;
}
if(cu_ID != null){
sql_eco += " and CustomerID ='" + cu_ID + "'";
}
要改进此代码,您可以使用stringbuilder/stringbuffer