select
moduleId, actionId
from
StatMemberAction
#[]#
order by
moduleId
select
moduleId, actionId
from
StatMemberAction
#[]#
order by
moduleId
说明:注意select的标签中没有parameterClass一项
另:这里也可以把数组放进一个hashMap中,但增加额外开销,不建议使用
6.让ibatis把参数直接解析成字符串
select
count(distinct memberId)
from
MemberAccessLog
where
accessTimestamp >= #start#
and accessTimestamp < #end#
and actionId in $actionIdString$
select
count(distinct memberId)
from
MemberAccessLog
where
accessTimestamp >= #start#
and accessTimestamp < #end#
and actionId in $actionIdString$
select
samplingTimestamp,onlineNum,year,
month,week,day,hour
from
onlineMemberNum
where samplingTimestamp <= #samplingTimestamp#
select
samplingTimestamp,onlineNum,year,
month,week,day,hour
from
onlineMemberNum
where samplingTimestamp <= #samplingTimestamp#
SELECT
a.answererCategoryId, a.answererId, a.answererName,
a.questionCategoryId, a.score, a.answeredNum,
a.correctNum, a.answerSeconds, a.createdTimestamp,
a.lastQuestionApprovedTimestamp, a.lastModified, GROUP_CONCAt(q.categoryName) as categoryName
FROM
AnswererCategory a, QuestionCategory q
WHERe a.questionCategoryId = q.questionCategoryId
GROUP BY a.answererId
ORDER BY a.answererCategoryId
SELECT
a.answererCategoryId, a.answererId, a.answererName,
a.questionCategoryId, a.score, a.answeredNum,
a.correctNum, a.answerSeconds, a.createdTimestamp,
a.lastQuestionApprovedTimestamp, a.lastModified, GROUP_CONCAt(q.categoryName) as categoryName
FROM
AnswererCategory a, QuestionCategory q
WHERe a.questionCategoryId = q.questionCategoryId
GROUP BY a.answererId
ORDER BY a.answererCategoryId
注:SQL中使用了MySQL的GROUP_CONCAT函数
12.按照IN里面的顺序进行排序
①MySQL:
select
moduleId, moduleName,
status, lastModifierId, lastModifiedName,
lastModified
from
StatModule
where
moduleId in (3, 5, 1)
order by
instr(',3,5,1,' , ','+ltrim(moduleId)+',')
select
moduleId, moduleName,
status, lastModifierId, lastModifiedName,
lastModified
from
StatModule
where
moduleId in (3, 5, 1)
order by
instr(',3,5,1,' , ','+ltrim(moduleId)+',')
②SQLSERVER:
select
moduleId, moduleName,
status, lastModifierId, lastModifiedName,
lastModified
from
StatModule
where
moduleId in (3, 5, 1)
order by
charindex(','+ltrim(moduleId)+',' , ',3,5,1,')
select
moduleId, moduleName,
status, lastModifierId, lastModifiedName,
lastModified
from
StatModule
where
moduleId in (3, 5, 1)
order by
charindex(','+ltrim(moduleId)+',' , ',3,5,1,')