一个简单查询,已有6个参数,SQL脚本如下: SELECT * FROM Table1 WITH (NOLOCK) WHERE 1=1 ${if(len(p_depot)=0,"","AND depot_code LIKE '"+p_depot+"%'")} ${if(len(p_region)=0,"","AND depot_region in ('"+p_region+"')")} ${if(len(p_province)=0,"","AND depot_province in ('"+p_province+"')")} ${if(len(p_city)=0,"","AND depot_city in ('"+p_city+"')")} ${if(len(p_deptyp_c)=0,"","AND depot_type in ('"+p_deptyp_c+"')")} ${if(len(p_Store)=0,"","AND depot_name in ('"+p_Store+"')")} 想增加一个复选框chkName,当这个复选框为选中的时候,执行查询条件 AND depot_name='AAA',同时忽略其他6个参数的条件。如这个复选框没有被选中,继续保持上面6个参数的查询逻辑。这个语句该怎么写? |