{"id":5992,"date":"2024-11-14T10:13:33","date_gmt":"2024-11-14T02:13:33","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5992\/"},"modified":"2024-11-14T10:13:33","modified_gmt":"2024-11-14T02:13:33","slug":"sql-where%e4%bb%80%e4%b9%88%e6%84%8f%e6%80%9d","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5992\/","title":{"rendered":"sql where\u4ec0\u4e48\u610f\u601d"},"content":{"rendered":"<blockquote><p>\n  where \u5b50\u53e5\u662f sql \u67e5\u8be2\u4e2d\u7b5b\u9009\u7ed3\u679c\u7684\u53ef\u9009\u90e8\u5206\uff0c\u5b83\u4f7f\u7528\u5e03\u5c14\u8868\u8fbe\u5f0f\u6765\u9650\u5236\u8fd4\u56de\u7684\u884c\u6570\uff0c\u7b5b\u9009\u6570\u636e\u5e76\u68c0\u7d22\u7279\u5b9a\u4fe1\u606f\u3002\u8fd9\u4e9b\u8868\u8fbe\u5f0f\u53ef\u4ee5\u4f7f\u7528\u5e03\u5c14\u8fd0\u7b97\u7b26\u3001\u6bd4\u8f83\u8fd0\u7b97\u7b26\u548c\u66f4\u9ad8\u7ea7\u7684\u529f\u80fd\uff0c\u4f8b\u5982\u5b50\u67e5\u8be2\u3001in\/not in\u3001like \u548c between\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/12\/2024061204421842165.jpg\" class=\"aligncenter\" title=\"sql where\u4ec0\u4e48\u610f\u601d\u63d2\u56fe\" alt=\"sql where\u4ec0\u4e48\u610f\u601d\u63d2\u56fe\" \/><\/p>\n<p><strong>WHERE \u5b50\u53e5\u5728 SQL \u4e2d\u7684\u542b\u4e49<\/strong><\/p>\n<p><strong>WHERE \u5b50\u53e5<\/strong>\u662f SQL \u67e5\u8be2\u8bed\u53e5\u4e2d\u7684\u4e00\u4e2a\u53ef\u9009\u90e8\u5206\uff0c\u7528\u4e8e\u7b5b\u9009\u7ed3\u679c\u96c6\uff0c\u4ec5\u8fd4\u56de\u6ee1\u8db3\u6307\u5b9a\u6761\u4ef6\u7684\u884c\u3002\u5176\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>SELECT ...\nFROM ...\nWHERE condition;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>condition<\/strong> \u53c2\u6570\u662f\u4e00\u4e2a\u5e03\u5c14\u8868\u8fbe\u5f0f\uff0c\u7528\u4e8e\u5bf9\u8868\u4e2d\u7684\u884c\u8fdb\u884c\u8bc4\u4f30\u3002\u5982\u679c\u8868\u8fbe\u5f0f\u4e3a\u771f\uff0c\u5219\u8fd4\u56de\u8be5\u884c\uff1b\u5982\u679c\u4e3a\u5047\uff0c\u5219\u8be5\u884c\u88ab\u6392\u9664\u5728\u7ed3\u679c\u96c6\u4e4b\u5916\u3002<\/p>\n<p><strong>WHERE \u5b50\u53e5\u7684\u4f5c\u7528<\/strong><\/p>\n<p>WHERE \u5b50\u53e5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u5e2e\u52a9\u7b5b\u9009\u7ed3\u679c\u96c6\uff1a<\/p>\n<ul>\n<li>\u9650\u5236\u8fd4\u56de\u7684\u884c\u6570<\/li>\n<li>\u6839\u636e\u7279\u5b9a\u6807\u51c6\u7b5b\u9009\u6570\u636e<\/li>\n<li>\u4ece\u8868\u4e2d\u68c0\u7d22\u7279\u5b9a\u4fe1\u606f<\/li>\n<\/ul>\n<p><strong>\u7528\u6cd5\u793a\u4f8b<\/strong><\/p>\n<p>\u4ee5\u4e0b\u793a\u4f8b\u67e5\u8be2\u663e\u793a\u4e86 WHERE \u5b50\u53e5\u7684\u7528\u6cd5\uff1a<\/p>\n<pre>SELECT name\nFROM customers\nWHERE age &gt; 30;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6b64\u67e5\u8be2\u5c06\u4ece &#8220;customers&#8221; \u8868\u4e2d\u8fd4\u56de\u6240\u6709\u5e74\u9f84\u5927\u4e8e 30 \u5c81\u5ba2\u6237\u7684\u59d3\u540d\u3002<\/p>\n<p><strong>\u4f7f\u7528\u8fd0\u7b97\u7b26<\/strong><\/p>\n<p>\u6761\u4ef6\u8868\u8fbe\u5f0f\u53ef\u4ee5\u5305\u542b\u5e03\u5c14\u8fd0\u7b97\u7b26\uff08\u5982 AND\u3001OR\u3001NOT\uff09\u548c\u6bd4\u8f83\u8fd0\u7b97\u7b26\uff08\u5982 =\u3001&gt;\u3001<\/p>\n<p><strong>\u9ad8\u7ea7 WHERE \u5b50\u53e5<\/strong><\/p>\n<p>WHERE \u5b50\u53e5\u8fd8\u652f\u6301\u4ee5\u4e0b\u66f4\u9ad8\u7ea7\u7684\u529f\u80fd\uff1a<\/p>\n<ul>\n<li>\u5b50\u67e5\u8be2\uff1a\u5c06\u4e00\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\u5d4c\u5165\u53e6\u4e00\u4e2a\u67e5\u8be2\u4e2d<\/li>\n<li>IN \u548c NOT IN\uff1a\u68c0\u67e5\u6307\u5b9a\u503c\u662f\u5426\u5305\u542b\u6216\u4e0d\u5305\u542b\u5728\u5217\u8868\u4e2d<\/li>\n<li>LIKE\uff1a\u6267\u884c\u6a21\u7cca\u5339\u914d<\/li>\n<li>BETWEEN\uff1a\u68c0\u67e5\u503c\u662f\u5426\u4ecb\u4e8e\u6307\u5b9a\u8303\u56f4\u4e4b\u5185<\/li>\n<\/ul>\n<p>\u4e86\u89e3 WHERE \u5b50\u53e5\u7684\u542b\u4e49\u548c\u7528\u6cd5\u5bf9\u4e8e\u7f16\u5199\u6709\u6548\u7684 SQL \u67e5\u8be2\u81f3\u5173\u91cd\u8981\u3002\u5b83\u4f7f\u6211\u4eec\u80fd\u591f\u4ece\u8868\u4e2d\u68c0\u7d22\u7279\u5b9a\u6570\u636e\uff0c\u4ece\u800c\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\u548c\u6570\u636e\u51c6\u786e\u6027\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fsql where\u4ec0\u4e48\u610f\u601d\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>where \u5b50\u53e5\u662f sql \u67e5\u8be2\u4e2d\u7b5b\u9009\u7ed3\u679c\u7684\u53ef\u9009\u90e8\u5206\uff0c\u5b83\u4f7f\u7528\u5e03\u5c14\u8868\u8fbe\u5f0f\u6765\u9650\u5236\u8fd4\u56de\u7684\u884c\u6570\uff0c\u7b5b\u9009\u6570\u636e\u5e76\u68c0\u7d22\u7279\u5b9a\u4fe1\u606f\u3002\u8fd9\u4e9b\u8868\u8fbe\u5f0f\u53ef\u4ee5\u4f7f\u7528\u5e03\u5c14\u8fd0\u7b97\u7b26\u3001\u6bd4\u8f83\u8fd0\u7b97\u7b26\u548c\u66f4\u9ad8\u7ea7\u7684\u529f\u80fd\uff0c\u4f8b\u5982\u5b50\u67e5\u8be2\u3001in\/not in\u3001like \u548c between\u3002 WHERE \u5b50\u53e5\u5728 SQL \u4e2d\u7684\u542b\u4e49 WHERE \u5b50\u53e5\u662f SQL \u67e5\u8be2\u8bed\u53e5\u4e2d\u7684\u4e00\u4e2a\u53ef\u9009\u90e8\u5206\uff0c\u7528\u4e8e\u7b5b\u9009\u7ed3\u679c\u96c6\uff0c\u4ec5\u8fd4\u56de\u6ee1\u8db3\u6307\u5b9a\u6761\u4ef6\u7684\u884c\u3002\u5176\u8bed\u6cd5\u5982\u4e0b\uff1a SELECT &#8230; FROM &#8230; WHERE condition; \u767b\u5f55\u540e\u590d\u5236 condition \u53c2\u6570\u662f\u4e00\u4e2a\u5e03\u5c14\u8868\u8fbe\u5f0f\uff0c\u7528\u4e8e\u5bf9\u8868\u4e2d\u7684\u884c\u8fdb\u884c\u8bc4\u4f30\u3002\u5982\u679c\u8868\u8fbe\u5f0f\u4e3a\u771f\uff0c\u5219\u8fd4\u56de\u8be5\u884c\uff1b\u5982\u679c\u4e3a\u5047\uff0c\u5219\u8be5\u884c\u88ab\u6392\u9664\u5728\u7ed3\u679c\u96c6\u4e4b\u5916\u3002 WHERE \u5b50\u53e5\u7684\u4f5c\u7528 WHERE \u5b50\u53e5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u5e2e\u52a9\u7b5b\u9009\u7ed3\u679c\u96c6\uff1a \u9650\u5236\u8fd4\u56de\u7684\u884c\u6570 \u6839\u636e\u7279\u5b9a\u6807\u51c6\u7b5b\u9009\u6570\u636e \u4ece\u8868\u4e2d\u68c0\u7d22\u7279\u5b9a\u4fe1\u606f \u7528\u6cd5\u793a\u4f8b \u4ee5\u4e0b\u793a\u4f8b\u67e5\u8be2\u663e\u793a\u4e86 WHERE \u5b50\u53e5\u7684\u7528\u6cd5\uff1a SELECT name FROM customers WHERE age &gt; 30; \u767b\u5f55\u540e\u590d\u5236 \u6b64\u67e5\u8be2\u5c06\u4ece &#8220;customers&#8221; \u8868\u4e2d\u8fd4\u56de\u6240\u6709\u5e74\u9f84\u5927\u4e8e 30 \u5c81\u5ba2\u6237\u7684\u59d3\u540d\u3002 \u4f7f\u7528\u8fd0\u7b97\u7b26 \u6761\u4ef6\u8868\u8fbe\u5f0f\u53ef\u4ee5\u5305\u542b\u5e03\u5c14\u8fd0\u7b97\u7b26\uff08\u5982 AND\u3001OR\u3001NOT\uff09\u548c\u6bd4\u8f83\u8fd0\u7b97\u7b26\uff08\u5982 =\u3001&gt;\u3001 \u9ad8\u7ea7 WHERE [&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-5992","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5992","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=5992"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5992\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5992"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5992"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5992"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}