Writing various statements in Oracle is handy, but in the Mybatis.xml file?

Source: Internet
Author: User
Tags cdata

This question I let me engage in the most of the day, really irritating, words do not say, directly on the code

<select id= "*" resultmap= "Blog" parametertype= "Integer" >
SELECT * (SELECT COUNT (*) from table_name C where c.bbs_id=t.id) as Plcount,//subquery plcount to sort virtual fields
From table_name t <! [cdata[where RowNum <=10]]> order BY t.pvcount Desc//mybatis not identified < or; [cdata[where rownum <=10]]> can
</select>

Writing the INSERT statement

<insert id= "*" parametertype= "Blog" >
<selectkey order= "Before" resulttype= "Java.lang.Long" keyproperty= "id" >
Select Zdcj_blog_seq. Nextval from dual//sequence, when added in the background, the constructor does not have a sequence 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},#{pvcou Nt,jdbctype=varchar},#{createdate,jdbctype=varchar},#{createuserid,jdbctype=numeric},#{popularity,jdbctype= VARCHAR})
</insert>

This is my own thought out of the table connection query, the effect can be achieved, may not be too professional, please understand

<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>

Writing various statements in Oracle is handy, but in the Mybatis.xml file?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.