{"id":5883,"date":"2024-11-14T12:10:36","date_gmt":"2024-11-14T04:10:36","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5883\/"},"modified":"2024-11-14T12:10:36","modified_gmt":"2024-11-14T04:10:36","slug":"sql%e6%80%8e%e4%b9%88%e6%b7%bb%e5%8a%a0%e5%a4%9a%e4%b8%aawhere","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5883\/","title":{"rendered":"sql\u600e\u4e48\u6dfb\u52a0\u591a\u4e2awhere"},"content":{"rendered":"<blockquote><p>\n  \u662f\u7684\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u4e2a where \u5b50\u53e5\u6765\u6839\u636e\u591a\u4e2a\u6761\u4ef6\u7b5b\u9009\u6570\u636e\u3002\u8bed\u6cd5\uff1aselect &#8230; from &#8230; where \u6761\u4ef61 and \u6761\u4ef62 &#8230; and \u6761\u4ef6n\uff1band \u8fd0\u7b97\u7b26\u8fde\u63a5\u5b50\u53e5\uff0c\u6240\u6709\u5b50\u53e5\u5fc5\u987b\u4e3a\u771f\uff1bor \u8fd0\u7b97\u7b26\u53ef\u7528\u4e8e\u53ea\u8981\u4e00\u4e2a\u5b50\u53e5\u4e3a\u771f\u5c31\u8fd4\u56de\u884c\uff1b\u62ec\u53f7\u53ef\u7528\u4e8e\u63a7\u5236\u6267\u884c\u987a\u5e8f\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/03\/2024060321391760847.jpg\" class=\"aligncenter\" title=\"sql\u600e\u4e48\u6dfb\u52a0\u591a\u4e2awhere\u63d2\u56fe\" alt=\"sql\u600e\u4e48\u6dfb\u52a0\u591a\u4e2awhere\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528 SQL \u6dfb\u52a0\u591a\u4e2a WHERE \u5b50\u53e5<\/strong><\/p>\n<p>\u5728 SQL \u4e2d\uff0cWHERE \u5b50\u53e5\u7528\u4e8e\u6307\u5b9a\u67e5\u8be2\u4e2d\u8fd4\u56de\u7684\u884c\u5fc5\u987b\u6ee1\u8db3\u7684\u6761\u4ef6\u3002\u5f53\u60a8\u9700\u8981\u6839\u636e\u591a\u4e2a\u6761\u4ef6\u7b5b\u9009\u6570\u636e\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u4e2a WHERE \u5b50\u53e5\u3002<\/p>\n<p><strong>\u8bed\u6cd5\uff1a<\/strong><\/p>\n<pre>SELECT ...\nFROM ...\nWHERE \u6761\u4ef61\nAND \u6761\u4ef62\n...\nAND \u6761\u4ef6n;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u5047\u8bbe\u60a8\u6709\u4e00\u4e2a\u540d\u4e3a &#8220;Customers&#8221; \u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u5ba2\u6237\u4fe1\u606f\uff0c\u5305\u62ec &#8220;FirstName&#8221;\u3001&#8221;LastName&#8221; \u548c &#8220;Age&#8221; \u5217\u3002\u8981\u8fd4\u56de\u6240\u6709\u5e74\u9f84\u5728 25 \u5c81\u4ee5\u4e0a\u4e14\u59d3\u6c0f\u4e3a &#8220;Smith&#8221; \u7684\u5ba2\u6237\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u67e5\u8be2\uff1a<\/p>\n<pre>SELECT *\nFROM Customers\nWHERE Age &gt; 25\nAND LastName = 'Smith';<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>AND \u8fd0\u7b97\u7b26\uff1a<\/strong><\/p>\n<p>AND \u8fd0\u7b97\u7b26\u7528\u4e8e\u8fde\u63a5\u591a\u4e2a WHERE \u5b50\u53e5\u3002\u5b83\u6307\u5b9a\u6240\u6709\u5b50\u53e5\u90fd\u5fc5\u987b\u4e3a\u771f\uff0c\u67e5\u8be2\u624d\u4f1a\u8fd4\u56de\u884c\u3002<\/p>\n<p><strong>OR \u8fd0\u7b97\u7b26\uff1a<\/strong><\/p>\n<p>OR \u8fd0\u7b97\u7b26\u4e5f\u53ef\u4ee5\u7528\u4e8e\u8fde\u63a5 WHERE \u5b50\u53e5\u3002\u5b83\u6307\u5b9a\u53ea\u8981\u5176\u4e2d\u4e00\u4e2a\u5b50\u53e5\u4e3a\u771f\uff0c\u67e5\u8be2\u5c31\u4f1a\u8fd4\u56de\u884c\u3002<\/p>\n<p><strong>\u62ec\u53f7\uff1a<\/strong><\/p>\n<p>\u62ec\u53f7\u53ef\u7528\u4e8e\u63a7\u5236 WHERE \u5b50\u53e5\u7684\u6267\u884c\u987a\u5e8f\u3002\u5c06\u6761\u4ef6\u62ec\u8d77\u6765\u4f1a\u5bfc\u81f4\u5b83\u4eec\u9996\u5148\u88ab\u8bc4\u4f30\u3002<\/p>\n<p><strong>\u4f8b\uff1a<\/strong><\/p>\n<p>\u4ee5\u4e0b\u67e5\u8be2\u8fd4\u56de\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\u4e4b\u4e00\u7684\u5ba2\u6237\uff1a\u5e74\u9f84\u5927\u4e8e 25 \u5c81\uff0c\u6216\u8005\u59d3\u6c0f\u4e3a &#8220;Smith&#8221;\uff1a<\/p>\n<pre>SELECT *\nFROM Customers\nWHERE (Age &gt; 25)\nOR (LastName = 'Smith');<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<ul>\n<li>WHERE \u5b50\u53e5\u53ef\u4ee5\u6309\u4efb\u4f55\u987a\u5e8f\u7f16\u5199\u3002<\/li>\n<li>\u53ef\u4ee5\u4f7f\u7528\u4efb\u610f\u6570\u91cf\u7684 WHERE \u5b50\u53e5\u3002<\/li>\n<li>\u786e\u4fdd\u6761\u4ef6\u7684\u987a\u5e8f\u6b63\u786e\uff0c\u4ee5\u83b7\u5f97\u9884\u671f\u7684\u7ed3\u679c\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fsql\u600e\u4e48\u6dfb\u52a0\u591a\u4e2awhere\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>\u662f\u7684\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u4e2a where \u5b50\u53e5\u6765\u6839\u636e\u591a\u4e2a\u6761\u4ef6\u7b5b\u9009\u6570\u636e\u3002\u8bed\u6cd5\uff1aselect &#8230; from &#8230; where \u6761\u4ef61 and \u6761\u4ef62 &#8230; and \u6761\u4ef6n\uff1band \u8fd0\u7b97\u7b26\u8fde\u63a5\u5b50\u53e5\uff0c\u6240\u6709\u5b50\u53e5\u5fc5\u987b\u4e3a\u771f\uff1bor \u8fd0\u7b97\u7b26\u53ef\u7528\u4e8e\u53ea\u8981\u4e00\u4e2a\u5b50\u53e5\u4e3a\u771f\u5c31\u8fd4\u56de\u884c\uff1b\u62ec\u53f7\u53ef\u7528\u4e8e\u63a7\u5236\u6267\u884c\u987a\u5e8f\u3002 \u5982\u4f55\u4f7f\u7528 SQL \u6dfb\u52a0\u591a\u4e2a WHERE \u5b50\u53e5 \u5728 SQL \u4e2d\uff0cWHERE \u5b50\u53e5\u7528\u4e8e\u6307\u5b9a\u67e5\u8be2\u4e2d\u8fd4\u56de\u7684\u884c\u5fc5\u987b\u6ee1\u8db3\u7684\u6761\u4ef6\u3002\u5f53\u60a8\u9700\u8981\u6839\u636e\u591a\u4e2a\u6761\u4ef6\u7b5b\u9009\u6570\u636e\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u4e2a WHERE \u5b50\u53e5\u3002 \u8bed\u6cd5\uff1a SELECT &#8230; FROM &#8230; WHERE \u6761\u4ef61 AND \u6761\u4ef62 &#8230; AND \u6761\u4ef6n; \u767b\u5f55\u540e\u590d\u5236 \u793a\u4f8b\uff1a \u5047\u8bbe\u60a8\u6709\u4e00\u4e2a\u540d\u4e3a &#8220;Customers&#8221; \u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u5ba2\u6237\u4fe1\u606f\uff0c\u5305\u62ec &#8220;FirstName&#8221;\u3001&#8221;LastName&#8221; \u548c &#8220;Age&#8221; \u5217\u3002\u8981\u8fd4\u56de\u6240\u6709\u5e74\u9f84\u5728 25 \u5c81\u4ee5\u4e0a\u4e14\u59d3\u6c0f\u4e3a &#8220;Smith&#8221; \u7684\u5ba2\u6237\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u67e5\u8be2\uff1a SELECT * FROM Customers [&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-5883","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5883","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=5883"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5883\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5883"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}