MySQL vs. Mabits size comparison, date comparison example

Source: Internet
Author: User

First, use MySQL to query the 60-day data from now

SelectCount (*), B1.record_datefromnk_house_use_record as B1, (Selecta.theme_id,a.theme_name,b.house_id,b.house_ Namefromnk_house_theme as a,nk_house as bwherea.theme_id = ' 08a649fd-b83e-41b5-b88b-99598d4c93fe ' and a.theme_id = B.theme_idand a.state = ' 1 ' and b.state = ' 1 ') as a1wherea1.house_id = B1.house_idand time1 = ' 0 ' and record_date >= CURD ATE () # ' 2016-06-05 ' and Record_date < Date_sub (Curdate (), INTERVAL-60 day) GROUP byb1.record_date

Second, porting to Mabits.

<SelectID= "Queryfreehousecalender"Resulttype= "Com.cn.front.entity.detail.FreeHouseCalender"ParameterType= "Com.cn.front.entity.input.QueryFreeHouse">SELECT Count (*) as NUM, b1.record_date from Nk_house_use_record as B1, (SELECT a.theme_id, A.theme_name, b.h ouse_id, b.house_name from Nk_house_theme as a, NK                _house as b WHERE a.theme_id = #{themeid} and a.theme_id = b.theme_id and a.state = ' 1 ' and b.state = ' 1 ') as A1 WHERE a1.house_id = B1 . house_id<ifTest= "TimeKey = = ' 1 '">and time1 = ' 0 '</if>                        <ifTest= "TimeKey = = ' 2 '">and time2 = ' 0 '</if>                        <ifTest= "TimeKey = = ' 3 '">and Time3 = ' 0 '</if>                        <ifTest= "TimeKey = = ' 4 '">and time4 = ' 0 ' and time5= ' 0 '</if>                    <ifTest= "StartDate! = null">and Record_date&gt;= #{startdate}</if>            <ifTest= "EndDate! = null">and Record_date&lt;= #{enddate}</if>                    <ifTest= "StartDate = = null">and Date (record_date)&gt;= Curdate ()</if>            <ifTest= "EndDate = = null">and Date (record_date)&lt;Date_sub (Curdate (), INTERVAL-60 Day)</if>GROUP by B1.record_date</Select>

XML special Symbol escape notation

&lt; <

&gt; >

&lt;&gt; <>

&amp; &

&apos; ‘

&quot; "

MySQL vs. Mabits size comparison, date comparison example

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.