<i id='6bbLh'><tr id='6bbLh'><dt id='6bbLh'><q id='6bbLh'><span id='6bbLh'><b id='6bbLh'><form id='6bbLh'><ins id='6bbLh'></ins><ul id='6bbLh'></ul><sub id='6bbLh'></sub></form><legend id='6bbLh'></legend><bdo id='6bbLh'><pre id='6bbLh'><center id='6bbLh'></center></pre></bdo></b><th id='6bbLh'></th></span></q></dt></tr></i><div id='6bbLh'><tfoot id='6bbLh'></tfoot><dl id='6bbLh'><fieldset id='6bbLh'></fieldset></dl></div>
<legend id='6bbLh'><style id='6bbLh'><dir id='6bbLh'><q id='6bbLh'></q></dir></style></legend>
      <bdo id='6bbLh'></bdo><ul id='6bbLh'></ul>

    1. <small id='6bbLh'></small><noframes id='6bbLh'>

      1. <tfoot id='6bbLh'></tfoot>
      2. MySQL选择带有日期的行

        时间:2023-10-08
        <i id='cvt1n'><tr id='cvt1n'><dt id='cvt1n'><q id='cvt1n'><span id='cvt1n'><b id='cvt1n'><form id='cvt1n'><ins id='cvt1n'></ins><ul id='cvt1n'></ul><sub id='cvt1n'></sub></form><legend id='cvt1n'></legend><bdo id='cvt1n'><pre id='cvt1n'><center id='cvt1n'></center></pre></bdo></b><th id='cvt1n'></th></span></q></dt></tr></i><div id='cvt1n'><tfoot id='cvt1n'></tfoot><dl id='cvt1n'><fieldset id='cvt1n'></fieldset></dl></div>

        <small id='cvt1n'></small><noframes id='cvt1n'>

        1. <tfoot id='cvt1n'></tfoot>
              <bdo id='cvt1n'></bdo><ul id='cvt1n'></ul>
              <legend id='cvt1n'><style id='cvt1n'><dir id='cvt1n'><q id='cvt1n'></q></dir></style></legend>
                <tbody id='cvt1n'></tbody>

                  本文介绍了MySQL选择带有日期的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在 MySQL 中我有这个查询

                  In MySQL I have this query

                  SELECT DISTINCT date, descr FROM book ORDER BY date
                  

                  日期格式为yyyy-mm-dd

                  我只想选择 2012 年 1 月 的书籍.我曾尝试使用 like 但这不起作用.

                  I want to select only the the books from January 2012. I have tried to use like but that does not work.

                  有什么想法吗?

                  推荐答案

                  Using DATE_FORMAT 函数

                  Using DATE_FORMAT function

                  SELECT DISTINCT date, descr FROM book 
                  WHERE DATE_FORMAT(date, '%Y %m') = DATE_FORMAT('2012-01-01', '%Y %m')
                  ORDER BY date
                  

                  或者使用 MONTHYEAR 函数

                  Or using MONTH and YEAR functions

                  SELECT DISTINCT date, descr FROM book 
                  WHERE Month(date) = Month('2012-01-01')
                  AND Year(date) = Year('2012-01-01')
                  ORDER BY date;
                  

                  或者使用BETWEEN 功能

                  Or using BETWEEN functions

                  SELECT DISTINCT date, descr FROM book 
                  WHERE date BETWEEN '2012-01-01'
                  AND '2012-01-31'
                  ORDER BY date;
                  

                  或者使用<=>= 运算符

                  Or using <= and >= operators

                  SELECT DISTINCT date, descr FROM book 
                  WHERE date >= '2012-01-01'
                  AND date <= '2012-01-31'
                  ORDER BY date;
                  

                  这篇关于MySQL选择带有日期的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:MySQL Tree 按父子顺序排序 下一篇:SQL 仅选择存在多个关系的行

                  相关文章

                1. <i id='akAL1'><tr id='akAL1'><dt id='akAL1'><q id='akAL1'><span id='akAL1'><b id='akAL1'><form id='akAL1'><ins id='akAL1'></ins><ul id='akAL1'></ul><sub id='akAL1'></sub></form><legend id='akAL1'></legend><bdo id='akAL1'><pre id='akAL1'><center id='akAL1'></center></pre></bdo></b><th id='akAL1'></th></span></q></dt></tr></i><div id='akAL1'><tfoot id='akAL1'></tfoot><dl id='akAL1'><fieldset id='akAL1'></fieldset></dl></div>

                    <tfoot id='akAL1'></tfoot>
                  1. <legend id='akAL1'><style id='akAL1'><dir id='akAL1'><q id='akAL1'></q></dir></style></legend>

                      <small id='akAL1'></small><noframes id='akAL1'>

                      • <bdo id='akAL1'></bdo><ul id='akAL1'></ul>