id,author_id as authorId,title,thumbnail,comments, is_comment as isComment, sync_status as syncStatus,status,summary,views,weight,category_id as categoryId,create_time as createTime,update_time as updateTime
SELECT
DISTINCT(posts.id),
posts.title,
posts.status,
posts.summary,
posts.thumbnail,
posts.sync_status syncStatus,
users.name author,
posts.views,
posts.comments,
posts.category_id as categoryId,
category.name as categoryName,
posts.weight,
posts.create_time createTime
FROM
posts posts
LEFT JOIN auth_user users ON users.id = posts.author_id
LEFT JOIN posts_tags postsTags ON postsTags.posts_id = posts.id
LEFT JOIN tags tags ON postsTags.tags_id = tags.id
LEFT JOIN category category ON category.id=posts.category_id
BETWEEN DATE_FORMAT( condition.archiveDate, "%Y-%m-01 00:00:00") AND DATE_FORMAT(condition.archiveDate, "%Y-%m-01 59:59:59" )
AND posts.create_time = #{condition.createTime}
AND (posts.title LIKE #{condition.keywords} OR posts.summary LIKE #{condition.keywords})
AND tags.name = #{condition.tagsName}
AND posts.category_id = #{condition.categoryId}
AND postsTags.tags_id = #{condition.postsTagsId}
AND posts.title LIKE #{condition.title}
AND posts.sync_status = #{condition.isPublishByteBlogs}
AND posts.status = #{condition.status}
ORDER BY posts.weight DESC
ORDER BY posts.id DESC
SELECT
id,
title,
create_time createTime,
DATE_FORMAT( create_time, "%Y" ) `year`
FROM
posts
ORDER BY
DATE_FORMAT( create_time, "%Y" ) DESC
SELECT
SUM(comments) commentsTotal,
SUM(views) viewsTotal
FROM
posts posts
SELECT
DATE_FORMAT( create_time, "%Y-%m-01 00:00:00" ) archiveDate,
COUNT(*) articleTotal
FROM
posts
GROUP BY DATE_FORMAT( create_time, "%Y-%m-01 00:00:00" )
ORDER BY id DESC
SELECT
posts.`id`,
posts.`author_id`,
posts.`title`,
posts.`thumbnail`,
posts.`comments`,
posts.`is_comment`,
posts.`sync_status`,
posts.`status`,
posts.`summary`,
posts.`views`,
posts.`weight`,
posts.`category_id`,
category.name as categoryName,
posts.`create_time`,
posts.`update_time`
FROM posts as posts
LEFT JOIN category as category ON category.id=posts.category_id
WHERE posts.id=#{id}
SELECT
FROM posts
WHERE DATE_FORMAT( create_time,"%Y-%m-01 00:00:00")= DATE_FORMAT(#{archiveDate}, "%Y-%m-01 00:00:00" )
SELECT COUNT(1) as articleTotal,SUM(views) as viewsTotal,SUM(comments) as commentsTotal
FROM `posts`
UPDATE posts SET views = views + 1 WHERE id = #{id}