{"id":3049,"date":"2016-12-15T10:18:16","date_gmt":"2016-12-15T02:18:16","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=3049"},"modified":"2016-12-15T10:18:16","modified_gmt":"2016-12-15T02:18:16","slug":"mysql%e7%9a%84between%e7%9a%84%e8%be%b9%e7%95%8c%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/3049.html","title":{"rendered":"MySQL\u7684between\u7684\u8fb9\u754c\u95ee\u9898"},"content":{"rendered":"<p>=Start=<\/p>\n<h4 id=\"MySQL\u7684between\u7684\u8fb9\u754c\u95ee\u9898-\u7f18\u7531\uff1a\">\u7f18\u7531\uff1a<\/h4>\n<p>\u4e4b\u524d\u5728\u5199\u4e00\u4e2aWeb\u5e94\u7528\u7684\u65f6\u5019\u78b0\u5230\u8fc7\u7c7b\u4f3c\u7684\u95ee\u9898\uff0c\u5f53\u65f6\u4e5f\u4e0d\u6e05\u695abetween\u7684\u8fb9\u754c\u5230\u5e95\u662f\u4e2a\u4ec0\u4e48\u60c5\u51b5\uff0c\u5c31\u7528\u300c&gt;\/&gt;=\/&lt;\/&lt;=\u300d\u66ff\u6362\u4e86\u3002\u4eca\u5929\u53c8\u78b0\u5230\u4e86\uff0c\u7d22\u6027\u5f7b\u5e95\u4e86\u89e3\u4e00\u4e0b\u3002<\/p>\n<h4 id=\"MySQL\u7684between\u7684\u8fb9\u754c\u95ee\u9898-\u6b63\u6587\uff1a\">\u6b63\u6587\uff1a<\/h4>\n<h5 id=\"MySQL\u7684between\u7684\u8fb9\u754c\u95ee\u9898-\u53c2\u8003\u89e3\u7b54\uff1a\">\u53c2\u8003\u89e3\u7b54\uff1a<\/h5>\n<p>\u5b98\u7f51\u4e0a\u7684\u8bf4\u660e\uff1a<\/p>\n<blockquote><p><a class=\"external-link\" href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/comparison-operators.html#operator_between\" target=\"_blank\" rel=\"nofollow\"><code class=\"literal\"><span class=\"replaceable\"><code>expr<\/code><\/span>\u00a0BETWEEN\u00a0<span class=\"replaceable\"><code>min<\/code><\/span>\u00a0AND\u00a0<span class=\"replaceable\"><code>max<\/code><\/span><\/code><\/a><\/p>\n<p>If\u00a0<span class=\"replaceable\"><code>expr<\/code><\/span>\u00a0is greater than or equal to\u00a0<span class=\"replaceable\"><code>min<\/code><\/span>\u00a0and\u00a0<span class=\"replaceable\"><code>expr<\/code><\/span>\u00a0is less than or equal to\u00a0<span class=\"replaceable\"><code>max<\/code><\/span>,\u00a0<a class=\"external-link\" href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/comparison-operators.html#operator_between\" target=\"_blank\" rel=\"nofollow\"><code class=\"literal\">BETWEEN<\/code><\/a>\u00a0returns\u00a0<code class=\"literal\">1<\/code>, otherwise it returns\u00a0<code class=\"literal\">0<\/code>. This is equivalent to the expression\u00a0<code class=\"literal\">(<span class=\"replaceable\"><code>min<\/code><\/span>\u00a0&lt;=<span class=\"replaceable\"><code>expr<\/code><\/span>\u00a0AND\u00a0<span class=\"replaceable\"><code>expr<\/code><\/span>\u00a0&lt;=\u00a0<span class=\"replaceable\"><code>max<\/code><\/span>)<\/code>\u00a0if all the arguments are of the same type. Otherwise type conversion takes place according to the rules described in\u00a0<a class=\"external-link\" href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/type-conversion.html\" target=\"_blank\" rel=\"nofollow\">Section\u00a013.2, \u201cType Conversion in Expression Evaluation\u201d<\/a>, but applied to all the three arguments.<\/p><\/blockquote>\n<p>\u5373\uff0cMySQL\u7684between\u662f\u5305\u542b\u4e24\u8fb9\u7684\u8fb9\u754c\u503c\u7684\uff0c\u7b49\u4ef7\u4e8e\u300cmin &lt;=expr AND expr &lt;= max\u300d\u3002<\/p>\n<p>\u53e6\u5916\u4e00\u4e2a\u300cnot between\u300d\uff1a<\/p>\n<blockquote><p><a class=\"external-link\" href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/comparison-operators.html#operator_not-between\" target=\"_blank\" rel=\"nofollow\"><code class=\"literal\"><span class=\"replaceable\"><code>expr<\/code><\/span>\u00a0NOT BETWEEN\u00a0<span class=\"replaceable\"><code>min<\/code><\/span>\u00a0AND\u00a0<span class=\"replaceable\"><code>max<\/code><\/span><\/code><\/a><\/p>\n<p>This is the same as\u00a0<code class=\"literal\">NOT (<span class=\"replaceable\"><code>expr<\/code><\/span>\u00a0BETWEEN\u00a0<span class=\"replaceable\"><code>min<\/code><\/span>\u00a0AND\u00a0<span class=\"replaceable\"><code>max<\/code><\/span>)<\/code>.<\/p><\/blockquote>\n<p>\u6240\u4ee5\uff0c\u300cnot between\u300d\u662f\u5bf9\u300cbetween\u300d\u7684\u53d6\u53cd\uff0c\u5219\u4e0d\u5305\u542b\u8fb9\u754c\u503c\uff0c\u7b49\u4ef7\u4e8e\u300cexpr\u00a0&lt; min OR expr &gt; max\u300d\u3002<\/p>\n<h5 id=\"MySQL\u7684between\u7684\u8fb9\u754c\u95ee\u9898-\u53c2\u8003\u94fe\u63a5\uff1a\">\u53c2\u8003\u94fe\u63a5\uff1a<\/h5>\n<ul>\n<li><a class=\"external-link\" href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/comparison-operators.html#operator_between\" target=\"_blank\" rel=\"nofollow\">http:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/comparison-operators.html#operator_between<\/a><\/li>\n<li><a class=\"external-link\" href=\"http:\/\/www.netingcn.com\/mysql-between.html\" target=\"_blank\" rel=\"nofollow\">http:\/\/www.netingcn.com\/mysql-between.html<\/a><\/li>\n<\/ul>\n<p>=END=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>=Start= \u7f18\u7531\uff1a \u4e4b\u524d\u5728\u5199\u4e00\u4e2aWeb\u5e94\u7528\u7684\u65f6\u5019\u78b0\u5230\u8fc7\u7c7b\u4f3c\u7684\u95ee\u9898\uff0c\u5f53\u65f6\u4e5f\u4e0d\u6e05\u695abetween\u7684\u8fb9\u754c\u5230\u5e95\u662f\u4e2a [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,23,7],"tags":[696,16],"class_list":["post-3049","post","type-post","status-publish","format-standard","hentry","category-database","category-knowledgebase-2","category-programing","tag-between","tag-mysql"],"views":2465,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/3049","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=3049"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/3049\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=3049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=3049"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=3049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}