sql语句(拼接条件后):SELECT DISTINCT article.id,article.title,article.content,article.summarize,article.publish_time as publish_time,article.page_views as pageViews ,
topic.id as topic_id, topic.name as topic_name, topic.summarize as topic_summarize ,
tag.id as tag_id, tag.name as tag_name
FROM tb_article article LEFT JOIN tb_topic topic ON article.topic_id = topic.id
LEFT JOIN tb_article_tag article_tag ON article.id = article_tag.article_id
LEFT JOIN tb_tag tag ON tag.id = article_tag.tag_id
ORDER BY article.id limit 0,5xml映射:<resultMap id="allResult" type="space.entity.Article">
<id column="id" property="id"/>
<result column="title" property="title"/>
<result column="content" property="content"/>
<result column="summarize" property="summarize"/>
<result column="publish_time" property="publishTime"/>
<result column="page_views" property="pageViews"/>
<association column="topic_id" property="topic" resultMap="space.dao.TopicDao.openResultMapper"/>
<collection property="tagList" ofType="Tag" resultMap="space.dao.TagDao.openResultMapper"/>
</resultMap>会出现这种情况mybatis会把两条记录合并成一条,就少了一条记录也出现了这种情况当两个条记录不在同一页,mybatis是看不到他们的,就会出现这种总数+1的情况现在问题来了,sql语句怎么写,才能把多对多的记录放在一行,并且配合mybatis的映射呢?
添加回答
举报
0/150
提交
取消