Skip to content

Instantly share code, notes, and snippets.

@sasajib
Created September 14, 2014 18:19
Show Gist options
  • Save sasajib/231b7299a09f117dbfbf to your computer and use it in GitHub Desktop.
Save sasajib/231b7299a09f117dbfbf to your computer and use it in GitHub Desktop.
<select id="findNewsCollection" parameterType="map" resultMap="newsSummary">
SELECT
id, slug, summary, created_at, viewed,
image, CONCAT(gtype,',', cleague, event,',', other) as tags
FROM news
<choose>
<when test="OnlyWorldCup != null">
WHERE is_worldcup=TRUE
</when>
<otherwise>
<if test="NewsType != null">
WHERE news_type=#{NewsType}
</if>
<if test="IsWorldCup != null">
AND WHERE is_worldcup=TRUE
</if>
</otherwise>
</choose>
ORDER BY id DESC
<choose>
<when test="From != null and To != null">
LIMIT #{From}, #{To} ;
</when>
<otherwise>
<choose>
<when test="Limit != null">
LIMIT #{Limit};
</when>
<otherwise>
LIMIT 6;
</otherwise>
</choose>
</otherwise>
</choose>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment