这个问题我让我搞了大半天,实在气人,话不多说,直接上代码
<select id="*" resultMap="Blog" parameterType="Integer">
		   select * (select count(*) from table_name c where c.bbs_id=t.id) as plcount,      //子查询     plcount为虚拟字段    排序 
		    from table_name t <![CDATA[ where rownum <=10 ]]> order by t.pvcount desc    //mybatis识别不出来<或>,用<![CDATA[ where rownum <=10 ]]>可以
	</select>
插入语句的编写
<insert id="*" parameterType="Blog">
		<selectKey order="BEFORE" resultType="java.lang.Long" keyProperty="id">
			  select ZDCJ_BLOG_SEQ.Nextval from dual         //序列,在后台执行添加的时候,构造函数没有序列ID
		</selectKey>
		  insert into table_name (ID,BBS_TITLE,BBS_CENTER,BBS_DATE,AUTHOR,AC,BANKUAI,PVCOUNT,CREATE_DATE,CREATE_USER,POPULARITY) values(#{id,jdbcType=NUMERIC},#          {bbsTitle,jdbcType=VARCHAR},#{bbsCenter,jdbcType=VARCHAR},#{bbsDate,jdbcType=VARCHAR},#{author,jdbcType=VARCHAR},#{ac,jdbcType=VARCHAR},#                   {bankuai,jdbcType=VARCHAR},#{pvcount,jdbcType=VARCHAR},#{createDate,jdbcType=VARCHAR},#{createUserid,jdbcType=NUMERIC},#{popularity,jdbcType=VARCHAR})
	</insert>
//这是我自己想出来的表连接查询,效果可以实现,可能不太专业,请谅解
<select id="*" resultType="Blog" parameterType="Integer">
		  select * from table_name1 u,table_name2 t where u.BLOG_ID = t.ID AND t.CREATE_USER=#{createUserid}
	</select>
在oracle里写各种语句得心应手,但是在mybatis.xml文件里呢?
原文:http://www.cnblogs.com/anpieBlog/p/5520841.html