SELECT * FROM `customtable` where l_Enterprise_code=${l_Enterprise_code} and l_server=${server} and l_uid=${uid} and 1=1 ${if(len(id) == 0,"","and id = '" + id + "'")} and 1=1 ${if(len(l_year) == 0,"","and l_year = '" + l_year + "'")} and 1=1 ${if(len(l_month) == 0,"","and l_month <= '" + l_month + "'")} 这是写的查询语句,如果不加参数时是可以查询到的。问题:1、加了参数不给值就报错。 2、给了值也报错。 不知是什么原因,请大神给个建议,是语句写的有问题还是有其它原因?求解? |
最佳回答 |
||||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|