SELECT p.ID,p.Code,p.Name,p.ReportType,q.ID as TemplateGroupID,q.Name as TemplateGroupName,p.IsActiveAssociation FROM Template p join TemplateGroup q on p.templategroupID=q.ID
<iftest="serviceTypeID!=null">
WHERE q.ServiceTypeID=#{serviceTypeID,jdbcType=VARCHAR}
SELECT p.ID as ID,q.ID as templateGroupID,p.Code as templateCode FROM Template p JOIN TemplateGroup q on p.TemplateGroupID=q.ID WHERE p.ID=#{ID,jdbcType=VARCHAR} LIMIT 1