SELECT COUNT(*) FROM tbl_news WHERE `tag` = :tag AND create_time < :time
</select>
<selectid="getListByHits">
SELECT * FROM tbl_news WHERE `tag` = :tag AND #where# ORDER BY create_time DESC LIMIT :offset, :limit
SELECT * FROM tbl_news WHERE `tag` = :tag AND #where# ORDER BY hits DESC LIMIT :offset, :limit
</select>
<selectid="getSameNewsById">
SELECT * FROM tbl_news WHERE id <> :news_id AND #where# AND id IN (
SELECT news_id FROM tbl_news_brand_rela WHERE brand_id IN (SELECT brand_id FROM tbl_news_brand_rela WHERE news_id = :news_id) )
</select>
<selectid="getLatestNews">
SELECT * FROM `tbl_news` #where# order by create_time DESC LIMIT :offset, :limit
</select>
<selectid="getListByDateHits">
SELECT * FROM tbl_news WHERE `tag` = :tag AND #where# ORDER BY UNIX_TIMESTAMP(FROM_UNIXTIME(create_time,'%Y-%m-%d')) DESC, hits DESC LIMIT :offset, :limit