方法1
SELECT ID,CODE,NAME,DESC,NOTE FROM SYS_TABLE <dynamic prepend="WHERE"> <isNotNull prepend="AND" property="code"> ( code LIKE '%$code$%') </isNotNull> <isNotNull prepend="AND" property="desc"> ( desc LIKE '%$desc$%') </isNotNull> <isNotNull prepend="AND" property="id"> ( id LIKE '%id%') </isNotNull> </dynamic>
参数:
Hashtable ht = new Hashtable(); ht.Add("code", "002"); ht.Add("desc", "这个是002");
方法2
SELECT
ID,CODE,NAME,DESC,NOTE
FROM
SYS_TABLE
<dynamic prepend="where"> <isParameterPresent> <isNotEmpty prepend="or" property="code" > CODE LIKE '%$code$%' </isNotEmpty> <isNotEmpty prepend="or" property="descr" > desc LIKE '%$desc$%' </isNotEmpty> <isNotEmpty prepend="or" property="id" > id LIKE '%$id$%' </isNotEmpty> </isParameterPresent> </dynamic>
注意事项
( desc LIKE '%$desc$%') 哈希的KEY 一定要用 美元符号圈住 用井号会报 错误的字段还是什么