{"id":5198,"date":"2024-11-14T10:22:20","date_gmt":"2024-11-14T02:22:20","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5198\/"},"modified":"2024-11-14T10:22:20","modified_gmt":"2024-11-14T02:22:20","slug":"sql%e4%b8%ador%e7%9a%84%e7%94%a8%e6%b3%95","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5198\/","title":{"rendered":"sql\u4e2dor\u7684\u7528\u6cd5"},"content":{"rendered":"<blockquote><p>\n  sql or \u8fd0\u7b97\u7b26\u7528\u4e8e\u7ec4\u5408\u5e03\u5c14\u8868\u8fbe\u5f0f\uff0c\u8fd4\u56de\u81f3\u5c11\u4e00\u4e2a\u8868\u8fbe\u5f0f\u4e3a\u771f\u7684\u5e03\u5c14\u7ed3\u679c\u3002\u7528\u6cd5\u5305\u62ec\uff1a\u591a\u4e2a\u6761\u4ef6\u5fc5\u987b\u6ee1\u8db3\u6761\u4ef6\u53ef\u4ee5\u4e92\u6362\u5b58\u5728\u591a\u4e2a\u641c\u7d22\u6761\u4ef6\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/24\/2024052420121898024.jpg\" class=\"aligncenter\" title=\"sql\u4e2dor\u7684\u7528\u6cd5\u63d2\u56fe\" alt=\"sql\u4e2dor\u7684\u7528\u6cd5\u63d2\u56fe\" \/><\/p>\n<p><strong>SQL \u4e2d OR \u8fd0\u7b97\u7b26\u7684\u7528\u6cd5<\/strong><\/p>\n<p>OR \u8fd0\u7b97\u7b26\u7528\u4e8e\u7ec4\u5408\u4e24\u4e2a\u6216\u66f4\u591a\u5e03\u5c14\u8868\u8fbe\u5f0f\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u5e03\u5c14\u7ed3\u679c\uff0c\u8868\u793a\u81f3\u5c11\u4e00\u4e2a\u8868\u8fbe\u5f0f\u4e3a\u771f\u3002<\/p>\n<p><strong>\u8bed\u6cd5\uff1a<\/strong><\/p>\n<pre>expr1 OR expr2 OR ...<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d\uff0cexpr1\u3001expr2 \u7b49\u662f\u5e03\u5c14\u8868\u8fbe\u5f0f\u6216\u5176\u4ed6\u903b\u8f91\u8868\u8fbe\u5f0f\u3002<\/p>\n<p><strong>\u7528\u6cd5\uff1a<\/strong><\/p>\n<p>OR \u8fd0\u7b97\u7b26\u5728\u4ee5\u4e0b\u573a\u666f\u4e2d\u5f88\u6709\u7528\uff1a<\/p>\n<ul>\n<li>\n<p><strong>\u5f53\u591a\u4e2a\u6761\u4ef6\u5fc5\u987b\u6ee1\u8db3\u65f6\uff1a<\/strong>\u4f8b\u5982\uff0c\u67e5\u8be2\u6240\u6709\u5728 2023 \u5e74\u6216 2024 \u5e74\u9500\u552e\u7684\u4ea7\u54c1\uff1a<\/p>\n<pre>SELECT * FROM products WHERE year = 2023 OR year = 2024;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236  <\/li>\n<li>\n<p><strong>\u5f53\u6761\u4ef6\u53ef\u4ee5\u4e92\u6362\u65f6\uff1a<\/strong>\u4f8b\u5982\uff0c\u67e5\u8be2\u6240\u6709\u5df2\u53d1\u8d27\u6216\u5df2\u4ed8\u6b3e\u7684\u8ba2\u5355\uff1a<\/p>\n<pre>SELECT * FROM orders WHERE status = 'shipped' OR status = 'paid';<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236  <\/li>\n<li>\n<p><strong>\u5f53\u5b58\u5728\u591a\u4e2a\u641c\u7d22\u6761\u4ef6\u65f6\uff1a<\/strong>\u4f8b\u5982\uff0c\u67e5\u8be2\u6240\u6709\u5305\u542b &#8220;apple&#8221; \u6216 &#8220;orange&#8221; \u7684\u4ea7\u54c1\u540d\u79f0\u7684\u4ea7\u54c1\uff1a<\/p>\n<pre>SELECT * FROM products WHERE name LIKE '%apple%' OR name LIKE '%orange%';<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236  <\/li>\n<\/ul>\n<p><strong>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff1a<\/strong><\/p>\n<ul>\n<li>OR \u8fd0\u7b97\u7b26\u7684\u4f18\u5148\u7ea7\u9ad8\u4e8e AND \u8fd0\u7b97\u7b26\uff0c\u56e0\u6b64\u5728\u6df7\u5408\u4f7f\u7528\u65f6\uff0c\u9700\u8981\u4f7f\u7528\u62ec\u53f7\u6765\u6307\u5b9a\u8fd0\u7b97\u987a\u5e8f\u3002<\/li>\n<li>OR \u8fd0\u7b97\u7b26\u53ef\u4ee5\u4e0e\u5176\u4ed6\u5e03\u5c14\u8fd0\u7b97\u7b26\uff0c\u5982 AND \u548c NOT\uff0c\u4e00\u8d77\u4f7f\u7528\u3002<\/li>\n<li>\u5728\u4f7f\u7528 OR \u8fd0\u7b97\u7b26\u65f6\uff0c\u5e94\u6ce8\u610f\u907f\u514d\u521b\u5efa\u5197\u4f59\u6216\u4e0d\u5fc5\u8981\u7684\u67e5\u8be2\u6761\u4ef6\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fsql\u4e2dor\u7684\u7528\u6cd5\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>sql or \u8fd0\u7b97\u7b26\u7528\u4e8e\u7ec4\u5408\u5e03\u5c14\u8868\u8fbe\u5f0f\uff0c\u8fd4\u56de\u81f3\u5c11\u4e00\u4e2a\u8868\u8fbe\u5f0f\u4e3a\u771f\u7684\u5e03\u5c14\u7ed3\u679c\u3002\u7528\u6cd5\u5305\u62ec\uff1a\u591a\u4e2a\u6761\u4ef6\u5fc5\u987b\u6ee1\u8db3\u6761\u4ef6\u53ef\u4ee5\u4e92\u6362\u5b58\u5728\u591a\u4e2a\u641c\u7d22\u6761\u4ef6 SQL \u4e2d OR \u8fd0\u7b97\u7b26\u7684\u7528\u6cd5 OR \u8fd0\u7b97\u7b26\u7528\u4e8e\u7ec4\u5408\u4e24\u4e2a\u6216\u66f4\u591a\u5e03\u5c14\u8868\u8fbe\u5f0f\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u5e03\u5c14\u7ed3\u679c\uff0c\u8868\u793a\u81f3\u5c11\u4e00\u4e2a\u8868\u8fbe\u5f0f\u4e3a\u771f\u3002 \u8bed\u6cd5\uff1a expr1 OR expr2 OR &#8230; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0cexpr1\u3001expr2 \u7b49\u662f\u5e03\u5c14\u8868\u8fbe\u5f0f\u6216\u5176\u4ed6\u903b\u8f91\u8868\u8fbe\u5f0f\u3002 \u7528\u6cd5\uff1a OR \u8fd0\u7b97\u7b26\u5728\u4ee5\u4e0b\u573a\u666f\u4e2d\u5f88\u6709\u7528\uff1a \u5f53\u591a\u4e2a\u6761\u4ef6\u5fc5\u987b\u6ee1\u8db3\u65f6\uff1a\u4f8b\u5982\uff0c\u67e5\u8be2\u6240\u6709\u5728 2023 \u5e74\u6216 2024 \u5e74\u9500\u552e\u7684\u4ea7\u54c1\uff1a SELECT * FROM products WHERE year = 2023 OR year = 2024; \u767b\u5f55\u540e\u590d\u5236 \u5f53\u6761\u4ef6\u53ef\u4ee5\u4e92\u6362\u65f6\uff1a\u4f8b\u5982\uff0c\u67e5\u8be2\u6240\u6709\u5df2\u53d1\u8d27\u6216\u5df2\u4ed8\u6b3e\u7684\u8ba2\u5355\uff1a SELECT * FROM orders WHERE status = &#8216;shipped&#8217; OR status = &#8216;paid&#8217;; \u767b\u5f55\u540e\u590d\u5236 \u5f53\u5b58\u5728\u591a\u4e2a\u641c\u7d22\u6761\u4ef6\u65f6\uff1a\u4f8b\u5982\uff0c\u67e5\u8be2\u6240\u6709\u5305\u542b &#8220;apple&#8221; [&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-5198","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5198","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=5198"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5198\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}