{"id":100,"date":"2019-12-04T16:25:25","date_gmt":"2019-12-04T08:25:25","guid":{"rendered":"http:\/\/blog.yuekegu.com\/?p=100"},"modified":"2019-12-04T16:25:25","modified_gmt":"2019-12-04T08:25:25","slug":"mysql%e6%9f%a5%e8%af%a2%e4%bb%8a%e5%a4%a9%e3%80%81%e6%98%a8%e5%a4%a9%e3%80%81%e6%9c%ac%e5%91%a8%e3%80%81%e6%9c%ac%e6%9c%88%e3%80%81%e6%9c%ac%e5%ad%a3%e3%80%81%e6%9c%ac%e5%b9%b4%e7%9a%84%e6%95%b0","status":"publish","type":"post","link":"https:\/\/book.yuekegu.com\/index.php\/2019\/12\/04\/mysql%e6%9f%a5%e8%af%a2%e4%bb%8a%e5%a4%a9%e3%80%81%e6%98%a8%e5%a4%a9%e3%80%81%e6%9c%ac%e5%91%a8%e3%80%81%e6%9c%ac%e6%9c%88%e3%80%81%e6%9c%ac%e5%ad%a3%e3%80%81%e6%9c%ac%e5%b9%b4%e7%9a%84%e6%95%b0\/","title":{"rendered":"MySQL\u67e5\u8be2\u4eca\u5929\u3001\u6628\u5929\u3001\u672c\u5468\u3001\u672c\u6708\u3001\u672c\u5b63\u3001\u672c\u5e74\u7684\u6570\u636e"},"content":{"rendered":"\n<p><strong>\u5b9e\u73b0\u67e5\u8be2\u51fa\u827e\u5bbe\u6d69\u65af\u8bb0\u5fc6\u89c4\u5f8b\u65f6\u95f4\u70b9\u7684\u6570\u636e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT id,from_unixtime(pubdate) FROM sq_question WHERE TO_DAYS( NOW( ) ) - TO_DAYS(from_unixtime(pubdate)) IN (1,2,4,7,15,30);<\/code><\/pre>\n\n\n\n<p><strong>\u4eca\u5929<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select * from \u8868\u540d where to_days(\u65f6\u95f4\u5b57\u6bb5\u540d) = to_days(now());<\/code><\/pre>\n\n\n\n<p><strong>\u6628\u5929<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * FROM \u8868\u540d WHERE TO_DAYS( NOW( ) ) - TO_DAYS( \u65f6\u95f4\u5b57\u6bb5\u540d) &lt;= 1<\/code><\/pre>\n\n\n\n<p><strong>\u8fd17\u5929<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * FROM \u8868\u540d where DATE_SUB(CURDATE(), INTERVAL 7 DAY) &lt;= date(\u65f6\u95f4\u5b57\u6bb5\u540d)<\/code><\/pre>\n\n\n\n<p><strong>\u8fd130\u5929<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * FROM \u8868\u540d where DATE_SUB(CURDATE(), INTERVAL 30 DAY) &lt;= date(\u65f6\u95f4\u5b57\u6bb5\u540d)<\/code><\/pre>\n\n\n\n<p><strong>\u672c\u6708<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * FROM \u8868\u540d WHERE DATE_FORMAT( \u65f6\u95f4\u5b57\u6bb5\u540d, '\n\n\n\n<p><strong>\u4e0a\u4e00\u6708<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT * FROM \u8868\u540d WHERE PERIOD_DIFF( date_format( now( ) , '\n\n\n\n<p><strong>\u67e5\u8be2\u672c\u5b63\u5ea6\u6570\u636e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select * from `ht_invoice_information` where QUARTER(create_date)=QUARTER(now());<\/code><\/pre>\n\n\n\n<p><strong>\u67e5\u8be2\u4e0a\u5b63\u5ea6\u6570\u636e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select * from `ht_invoice_information` where QUARTER(create_date)=QUARTER(DATE_SUB(now(),interval 1 QUARTER));<\/code><\/pre>\n\n\n\n<p><strong>\u67e5\u8be2\u672c\u5e74\u6570\u636e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select * from `ht_invoice_information` where YEAR(create_date)=YEAR(NOW());<\/code><\/pre>\n\n\n\n<p><strong>\u67e5\u8be2\u4e0a\u5e74\u6570\u636e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select * from `ht_invoice_information` where year(create_date)=year(date_sub(now(),interval 1 year));<\/code><\/pre>\n\n\n\n<p><strong>\u67e5\u8be2\u5f53\u524d\u8fd9\u5468\u7684\u6570\u636e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT name,submittime FROM enterprise WHERE YEARWEEK(date_format(submittime,'\n\n\n\n<p><strong>\u67e5\u8be2\u4e0a\u5468\u7684\u6570\u636e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT name,submittime FROM enterprise WHERE YEARWEEK(date_format(submittime,'\n\n\n\n<p><strong>\u67e5\u8be2\u4e0a\u4e2a\u6708\u7684\u6570\u636e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select name,submittime from enterprise where date_format(submittime,'\n\n\n\n<p><strong>\u67e5\u8be2\u5f53\u524d\u6708\u4efd\u7684\u6570\u636e&nbsp;<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select name,submittime from enterprise   where date_format(submittime,'\n\n\n\n<p><strong>\u67e5\u8be2\u8ddd\u79bb\u5f53\u524d\u73b0\u57286\u4e2a\u6708\u7684\u6570\u636e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>select name,submittime from enterprise where submittime between date_sub(now(),interval 6 month) and now();<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b9e\u73b0\u67e5\u8be2\u51fa\u827e\u5bbe\u6d69\u65af\u8bb0\u5fc6\u89c4\u5f8b\u65f6\u95f4\u70b9\u7684\u6570\u636e \u4eca\u5929 \u6628\u5929 \u8fd17\u5929 \u8fd130\u5929 \u672c\u6708 \u4e0a\u4e00\u6708 \u67e5\u8be2\u672c\u5b63\u5ea6\u6570\u636e \u67e5\u8be2\u4e0a\u5b63\u5ea6\u6570\u636e \u67e5\u8be2\u672c\u5e74\u6570\u636e \u67e5\u8be2\u4e0a\u5e74\u6570\u636e \u67e5\u8be2\u5f53\u524d\u8fd9\u5468\u7684\u6570\u636e \u67e5\u8be2\u4e0a\u5468\u7684\u6570\u636e \u67e5\u8be2\u4e0a\u4e2a\u6708\u7684\u6570\u636e \u67e5\u8be2\u5f53\u524d\u6708\u4efd\u7684\u6570\u636e&nbsp; \u67e5\u8be2\u8ddd\u79bb\u5f53\u524d\u73b0\u57286\u4e2a\u6708\u7684\u6570\u636e<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[],"class_list":["post-100","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/posts\/100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/comments?post=100"}],"version-history":[{"count":0,"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/posts\/100\/revisions"}],"wp:attachment":[{"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/media?parent=100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/categories?post=100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/tags?post=100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}