-3

我正在尝试执行以下操作,但它不接受它。

String sql_eco = "select * from orders where EmployeeID=" +e_ID + " and CustomerID ="' + cu_ID + "'";

从两个表和两个值(变量)中选择

4

4 回答 4

0

尝试,假设CustomerIDEmployeeID都是Integer列类型

String sql_eco = "select * from orders where EmployeeID=" +e_ID + " and CustomerID =" + cu_ID;
于 2013-04-17T18:40:33.047 回答
0

尝试这个:

String sql_eco = "select * +
                  from orders +
                  where EmployeeID=" +e_ID + " and CustomerID ='" + cu_ID + "'";   
                                                               ^                                                                         
于 2013-04-17T18:40:38.463 回答
0

用这个。您已经放错了“ for CustomerId

String sql_eco = "select * from orders where EmployeeID=" +e_ID + " and CustomerID ='" + cu_ID + "'";
于 2013-04-17T18:41:29.087 回答
0

values variable u wanna say something like this?

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 + "'";  
}

to improve this code u can use stringbuilder/stringbuffer

于 2013-04-17T19:00:50.600 回答