{"id":5965,"date":"2024-11-14T10:34:59","date_gmt":"2024-11-14T02:34:59","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5965\/"},"modified":"2024-11-14T10:34:59","modified_gmt":"2024-11-14T02:34:59","slug":"sql%e8%af%ad%e5%8f%a5between%e6%80%8e%e4%b9%88%e7%94%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5965\/","title":{"rendered":"sql\u8bed\u53e5between\u600e\u4e48\u7528"},"content":{"rendered":"<blockquote><p>\n  between \u8fd0\u7b97\u7b26\u68c0\u67e5\u503c\u662f\u5426\u4ecb\u4e8e\u6307\u5b9a\u8303\u56f4\u7684\u4e24\u4e2a\u503c\u4e4b\u95f4\u3002\u8bed\u6cd5\uff1aselect column_name from table_name where column_name between value1 and value2; \u7528\u9014\uff1a1. \u68c0\u67e5\u503c\u662f\u5426\u4ecb\u4e8e\u4e24\u4e2a\u7279\u5b9a\u503c\u4e4b\u95f4\uff1b2. \u8fc7\u6ee4\u4ecb\u4e8e\u6307\u5b9a\u8303\u56f4\u5185\u7684\u503c\uff1b3. \u521b\u5efa\u4ece\u4e00\u4e2a\u503c\u5230\u53e6\u4e00\u4e2a\u503c\u7684\u8303\u56f4\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/12\/2024061202512072124.jpg\" class=\"aligncenter\" title=\"sql\u8bed\u53e5between\u600e\u4e48\u7528\u63d2\u56fe\" alt=\"sql\u8bed\u53e5between\u600e\u4e48\u7528\u63d2\u56fe\" \/><\/p>\n<p><strong>SQL \u8bed\u53e5 BETWEEN \u7528\u6cd5<\/strong><\/p>\n<p><strong>\u4ec0\u4e48\u662f BETWEEN<\/strong><\/p>\n<p>BETWEEN \u662f\u4e00\u79cd SQL \u8fd0\u7b97\u7b26\uff0c\u7528\u4e8e\u68c0\u67e5\u4e00\u4e2a\u503c\u662f\u5426\u4ecb\u4e8e\u6307\u5b9a\u8303\u56f4\u7684\u4e24\u4e2a\u503c\u4e4b\u95f4\u3002<\/p>\n<p><strong>\u8bed\u6cd5<\/strong><\/p>\n<pre>SELECT column_name\nFROM table_name\nWHERE column_name BETWEEN value1 AND value2;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u53c2\u6570<\/strong><\/p>\n<ul>\n<li> <strong>column_name\uff1a<\/strong>\u8981\u68c0\u67e5\u7684\u503c\u6240\u5728\u7684\u5217\u540d\u3002<\/li>\n<li> <strong>value1\uff1a<\/strong>\u8303\u56f4\u7684\u4f4e\u503c\u3002<\/li>\n<li> <strong>value2\uff1a<\/strong>\u8303\u56f4\u7684\u9ad8\u503c\u3002<\/li>\n<\/ul>\n<p><strong>\u7528\u6cd5<\/strong><\/p>\n<p>BETWEEN \u8fd0\u7b97\u7b26\u7528\u4e8e\u4ee5\u4e0b\u573a\u666f\uff1a<\/p>\n<ul>\n<li>\u68c0\u67e5\u503c\u662f\u5426\u4ecb\u4e8e\u4e24\u4e2a\u7279\u5b9a\u503c\u4e4b\u95f4\u3002<\/li>\n<li>\u8fc7\u6ee4\u4ecb\u4e8e\u6307\u5b9a\u8303\u56f4\u5185\u7684\u503c\u3002<\/li>\n<li>\u521b\u5efa\u4ece\u4e00\u4e2a\u503c\u5230\u53e6\u4e00\u4e2a\u503c\u7684\u8303\u56f4\u3002<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<pre>SELECT *\nFROM students\nWHERE age BETWEEN 20 AND 30;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u8fd4\u56de\u8868\u4e2d\u5e74\u9f84\u4ecb\u4e8e 20 \u5c81\u5230 30 \u5c81\uff08\u5305\u62ec\u8fd9\u4e24\u4e2a\u503c\uff09\u7684\u6240\u6709\u5b66\u751f\u8bb0\u5f55\u3002<\/p>\n<p><strong>\u6ce8\u610f<\/strong><\/p>\n<ul>\n<li>BETWEEN \u8fd0\u7b97\u7b26\u662f\u5305\u542b\u7684\uff0c\u8fd9\u610f\u5473\u7740\u8303\u56f4\u7684\u4f4e\u503c\u548c\u9ad8\u503c\u90fd\u5c06\u88ab\u5305\u62ec\u5728\u5185\u3002<\/li>\n<li>BETWEEN \u8fd0\u7b97\u7b26\u53ef\u4ee5\u4e0e\u5176\u4ed6\u8fd0\u7b97\u7b26\u4e00\u8d77\u4f7f\u7528\uff0c\u4f8b\u5982 AND\u3001OR \u548c NOT\u3002<\/li>\n<li>\u5982\u679c\u8981\u68c0\u67e5\u503c\u662f\u5426\u4ec5\u5c0f\u4e8e\u6216\u5927\u4e8e\u6307\u5b9a\u503c\uff0c\u53ef\u4ee5\u4f7f\u7528 \u8fd0\u7b97\u7b26\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fbetween\u600e\u4e48\u7528\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>between \u8fd0\u7b97\u7b26\u68c0\u67e5\u503c\u662f\u5426\u4ecb\u4e8e\u6307\u5b9a\u8303\u56f4\u7684\u4e24\u4e2a\u503c\u4e4b\u95f4\u3002\u8bed\u6cd5\uff1aselect column_name from table_name where column_name between value1 and value2; \u7528\u9014\uff1a1. \u68c0\u67e5\u503c\u662f\u5426\u4ecb\u4e8e\u4e24\u4e2a\u7279\u5b9a\u503c\u4e4b\u95f4\uff1b2. \u8fc7\u6ee4\u4ecb\u4e8e\u6307\u5b9a\u8303\u56f4\u5185\u7684\u503c\uff1b3. \u521b\u5efa\u4ece\u4e00\u4e2a\u503c\u5230\u53e6\u4e00\u4e2a\u503c\u7684\u8303\u56f4\u3002 SQL \u8bed\u53e5 BETWEEN \u7528\u6cd5 \u4ec0\u4e48\u662f BETWEEN BETWEEN \u662f\u4e00\u79cd SQL \u8fd0\u7b97\u7b26\uff0c\u7528\u4e8e\u68c0\u67e5\u4e00\u4e2a\u503c\u662f\u5426\u4ecb\u4e8e\u6307\u5b9a\u8303\u56f4\u7684\u4e24\u4e2a\u503c\u4e4b\u95f4\u3002 \u8bed\u6cd5 SELECT column_name FROM table_name WHERE column_name BETWEEN value1 AND value2; \u767b\u5f55\u540e\u590d\u5236 \u53c2\u6570 column_name\uff1a\u8981\u68c0\u67e5\u7684\u503c\u6240\u5728\u7684\u5217\u540d\u3002 value1\uff1a\u8303\u56f4\u7684\u4f4e\u503c\u3002 value2\uff1a\u8303\u56f4\u7684\u9ad8\u503c\u3002 \u7528\u6cd5 BETWEEN \u8fd0\u7b97\u7b26\u7528\u4e8e\u4ee5\u4e0b\u573a\u666f\uff1a \u68c0\u67e5\u503c\u662f\u5426\u4ecb\u4e8e\u4e24\u4e2a\u7279\u5b9a\u503c\u4e4b\u95f4\u3002 \u8fc7\u6ee4\u4ecb\u4e8e\u6307\u5b9a\u8303\u56f4\u5185\u7684\u503c\u3002 \u521b\u5efa\u4ece\u4e00\u4e2a\u503c\u5230\u53e6\u4e00\u4e2a\u503c\u7684\u8303\u56f4\u3002 \u793a\u4f8b SELECT * FROM students WHERE age BETWEEN [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-5965","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5965","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=5965"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5965\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5965"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}