select count(*)
select *
from icp
name like '%$name$%'
path like '%path$%'
area_id = #area_id#
hided = #hided#
limit #_start#, #_size#
2、数字范围查询
所传参数名称是捏造所得,非数据库字段,比如_img_size_ge、_img_size_lt字段
= #_img_size_ge#
]]>
多次使用一个参数也是允许的
= #_now#
]]>
3、时间范围查询
= #_starttime#
and createtime < #_endtime#
]]>
4、in查询
state in ('$_in_state$')
5、like查询
(chnameone like '%$chnameone$%' or spellinitial like '%$chnameone$%')
chnametwo like '%$chnametwo$%'
6、or条件
7、where子查询
code not in
(select t.contentcode
from cms_ccm_programcontent t
where t.contenttype='MZNRLX_MA'
and t.programcode = #exprogramcode#)
select *
from cms_ccm_material
where code in
(select t.contentcode
from cms_ccm_programcontent t
where t.contenttype = 'MZNRLX_MA'
and programcode = #value#)
order by updatetime desc
9、函数的使用
insert into rulemaster(
name,
createtime,
updatetime,
remark
) values (
#name#,
now(),
now(),
#remark#
)
select LAST_INSERT_ID()
update rulemaster set
name = #name#,
updatetime = now(),
remark = #remark#
where id = #id#
10、map结果集
select count(a.*)
select a.id vid,
a.img imgurl,
a.img_s imgfile,
b.vfilename vfilename,
b.name name,
c.id sid,
c.url url,
c.filename filename,
c.status status
From secfiles c, juji b, videoinfo a
where
a.id = b. videoid
and b.id = c.segmentid
and c.status = 0
order by a.id asc,b.id asc,c.sortnum asc
limit #_start#, #_size#
11、trim
trim是更灵活的去处多余关键字的标签,他可以实践where和set的效果。
where例子的等效trim语句:
Xml代码
SELECT * from STUDENT_TBL ST
ST.STUDENT_NAME LIKE CONCAT(CONCAT('%', #{studentName}),'%')
AND ST.STUDENT_SEX = #{studentSex}
SELECT * from STUDENT_TBL ST
ST.STUDENT_NAME LIKE CONCAT(CONCAT('%', #{studentName}),'%')
AND ST.STUDENT_SEX = #{studentSex}
AND ST.STUDENT_BIRTHDAY = #{studentBirthday}
AND ST.CLASS_ID = #{classEntity.classID}