mybatis查詢mysql的時間段,mybatis查詢mysql

來源:互聯網
上載者:User

mybatis查詢mysql的時間段,mybatis查詢mysql

   mapper檔案的寫法為:(模糊查詢,查詢時間段)

                <if test="com_name!=null and com_name!=''">and sc.com_name like CONCAT(CONCAT('%',#{com_name}),'%')</if><if test="check_begin_date!=null and check_begin_date!=''"><![CDATA[  and DATE_FORMAT(tcb.check_begin_date, '%Y-%m-%d') >=  DATE_FORMAT(#{check_begin_date}, '%Y-%m-%d')]]></if><if test="check_end_date!=null and check_end_date!=''"><![CDATA[  and DATE_FORMAT(tcb.check_begin_date, '%Y-%m-%d') <=  DATE_FORMAT(#{check_end_date}, '%Y-%m-%d')]]></if>



mysql 時間段查詢

你的要求是 '2010-7-12 11:18:54' 到 '2010-7-12 11:22:20' 之間的
顯然2010-7-12 11:18:46 和 2010-7-12 11:22:22不在二者之間,為什麼要包含在結果集內?
我也附議樓上三位
select sum(csize) from table where cdtime between '2010-7-12 11:18:54' and '2010-7-12 11:22:20'
--------------------------------------------
那如果表裡再多一行 '2010-7-12 11:22:21', 結果集是6個還是5個?
這顯然屬於你的描述出了問題
--------------------------------------------
很遺憾,請給出更清晰的描述
即使用你的巢狀查詢,結果集也會是5,不會是6
 
Mybatis與Mysql的查詢語句一樣?

是的,可以。
你要搞清楚一個概念,我們在查詢關聯式資料庫時用到的語句是SQL,這是為大多數關聯式資料庫管理系統所支援的工業標準,所以不管我們是查Mysql還是查Oracle等資料庫都是一樣的SQL,不管是用java還是用C#,也是一樣的
 

相關文章

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.