{"id":5882,"date":"2024-11-14T08:24:32","date_gmt":"2024-11-14T00:24:32","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5882\/"},"modified":"2024-11-14T08:24:32","modified_gmt":"2024-11-14T00:24:32","slug":"sql%e4%b8%8d%e7%ad%89%e4%ba%8e%e7%a9%ba%e6%9d%a1%e4%bb%b6%e6%80%8e%e4%b9%88%e5%86%99","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5882\/","title":{"rendered":"sql\u4e0d\u7b49\u4e8e\u7a7a\u6761\u4ef6\u600e\u4e48\u5199"},"content":{"rendered":"<blockquote><p>\n  sql \u4e2d\u5904\u7406\u975e\u7a7a\u5b57\u6bb5\u7684\u6761\u4ef6\u5305\u62ec\uff1a1. is not null\uff1a\u9002\u7528\u4e8e\u6240\u6709\u6570\u636e\u7c7b\u578b\uff0c\u68c0\u67e5\u5b57\u6bb5\u662f\u5426\u4e0d\u4e3a null\uff1b2. != &#8221;\uff1a\u4ec5\u9002\u7528\u4e8e\u5b57\u7b26\u4e32\u5b57\u6bb5\uff0c\u68c0\u67e5\u5b57\u7b26\u4e32\u5b57\u6bb5\u662f\u5426\u4e0d\u4e3a\u7a7a\u5b57\u7b26\u4e32\u3002\u901a\u5e38\u63a8\u8350\u4f7f\u7528 is not null\uff0c\u5b83\u9002\u7528\u4e8e\u6240\u6709\u6570\u636e\u7c7b\u578b\u4e14\u8bed\u6cd5\u66f4\u7b80\u6d01\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/03\/2024060321363846954.jpg\" class=\"aligncenter\" title=\"sql\u4e0d\u7b49\u4e8e\u7a7a\u6761\u4ef6\u600e\u4e48\u5199\u63d2\u56fe\" alt=\"sql\u4e0d\u7b49\u4e8e\u7a7a\u6761\u4ef6\u600e\u4e48\u5199\u63d2\u56fe\" \/><\/p>\n<p><strong>SQL \u4e2d\u5904\u7406\u975e\u7a7a\u5b57\u6bb5\u7684\u6761\u4ef6<\/strong><\/p>\n<p>\u5728 SQL \u67e5\u8be2\u4e2d\uff0c\u5bf9\u4e8e\u975e\u7a7a\u5b57\u6bb5\uff0c\u6211\u4eec\u901a\u5e38\u4f7f\u7528\u4ee5\u4e0b\u4e24\u79cd\u65b9\u6cd5\u4e4b\u4e00\u6765\u6307\u5b9a\u6761\u4ef6\uff1a<\/p>\n<p><strong>1. IS NOT NULL<\/strong><\/p>\n<p>\u6b64\u6761\u4ef6\u68c0\u67e5\u5b57\u6bb5\u662f\u5426\u4e0d\u4e3a NULL\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>SELECT * FROM table_name WHERE column_name IS NOT NULL;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>2. != &#8221;<\/strong><\/p>\n<p>\u6b64\u6761\u4ef6\u68c0\u67e5\u5b57\u7b26\u4e32\u5b57\u6bb5\u662f\u5426\u4e0d\u4e3a\u7a7a\u5b57\u7b26\u4e32\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>SELECT * FROM table_name WHERE column_name != '';<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u9002\u7528\u60c5\u51b5<\/strong><\/p>\n<ul>\n<li> <strong>IS NOT NULL<\/strong> \u9002\u7528\u4e8e\u6240\u6709\u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ec\u6570\u5b57\u3001\u65e5\u671f\u548c\u5e03\u5c14\u503c\u3002<\/li>\n<li> <strong>!= &#8221;<\/strong> \u4ec5\u9002\u7528\u4e8e\u5b57\u7b26\u4e32\u5b57\u6bb5\u3002<\/li>\n<\/ul>\n<p><strong>\u54ea\u79cd\u65b9\u6cd5\u66f4\u597d\uff1f<\/strong><\/p>\n<p><strong>IS NOT NULL<\/strong> \u901a\u5e38\u662f\u9996\u9009\uff0c\u56e0\u4e3a\u5b83\u662f SQL \u6807\u51c6\u4e2d\u7684\u63a8\u8350\u65b9\u6cd5\u3002\u5b83\u9002\u7528\u4e8e\u6240\u6709\u6570\u636e\u7c7b\u578b\uff0c\u8bed\u6cd5\u66f4\u7b80\u6d01\u3002<\/p>\n<p><strong>!= &#8221;<\/strong> \u4ec5\u9002\u7528\u4e8e\u5b57\u7b26\u4e32\u5b57\u6bb5\uff0c\u5e76\u4e14\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u53ef\u80fd\u5bfc\u81f4\u6df7\u6dc6\u3002\u4f8b\u5982\uff0c\u5982\u679c\u5b57\u6bb5\u5305\u542b\u7a7a\u683c\uff0c\u5219 <strong>!= &#8221;<\/strong> \u6761\u4ef6\u5c06\u4e3a\u5047\uff0c\u800c <strong>IS NOT NULL<\/strong> \u6761\u4ef6\u4ecd\u5c06\u4e3a\u771f\u3002<\/p>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<p>\u4ee5\u4e0b\u793a\u4f8b\u5c55\u793a\u4e86\u5728\u67e5\u8be2\u4e2d\u4f7f\u7528 <strong>IS NOT NULL<\/strong> \u548c <strong>!= &#8221;<\/strong> \u6761\u4ef6\uff1a<\/p>\n<pre>-- IS NOT NULL\nSELECT * FROM table_name WHERE name IS NOT NULL;\n\n-- != ''\nSELECT * FROM table_name WHERE email != '';<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fsql\u4e0d\u7b49\u4e8e\u7a7a\u6761\u4ef6\u600e\u4e48\u5199\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 \u4e2d\u5904\u7406\u975e\u7a7a\u5b57\u6bb5\u7684\u6761\u4ef6\u5305\u62ec\uff1a1. is not null\uff1a\u9002\u7528\u4e8e\u6240\u6709\u6570\u636e\u7c7b\u578b\uff0c\u68c0\u67e5\u5b57\u6bb5\u662f\u5426\u4e0d\u4e3a null\uff1b2. != &#8221;\uff1a\u4ec5\u9002\u7528\u4e8e\u5b57\u7b26\u4e32\u5b57\u6bb5\uff0c\u68c0\u67e5\u5b57\u7b26\u4e32\u5b57\u6bb5\u662f\u5426\u4e0d\u4e3a\u7a7a\u5b57\u7b26\u4e32\u3002\u901a\u5e38\u63a8\u8350\u4f7f\u7528 is not null\uff0c\u5b83\u9002\u7528\u4e8e\u6240\u6709\u6570\u636e\u7c7b\u578b\u4e14\u8bed\u6cd5\u66f4\u7b80\u6d01\u3002 SQL \u4e2d\u5904\u7406\u975e\u7a7a\u5b57\u6bb5\u7684\u6761\u4ef6 \u5728 SQL \u67e5\u8be2\u4e2d\uff0c\u5bf9\u4e8e\u975e\u7a7a\u5b57\u6bb5\uff0c\u6211\u4eec\u901a\u5e38\u4f7f\u7528\u4ee5\u4e0b\u4e24\u79cd\u65b9\u6cd5\u4e4b\u4e00\u6765\u6307\u5b9a\u6761\u4ef6\uff1a 1. IS NOT NULL \u6b64\u6761\u4ef6\u68c0\u67e5\u5b57\u6bb5\u662f\u5426\u4e0d\u4e3a NULL\u3002\u4f8b\u5982\uff1a SELECT * FROM table_name WHERE column_name IS NOT NULL; \u767b\u5f55\u540e\u590d\u5236 2. != &#8221; \u6b64\u6761\u4ef6\u68c0\u67e5\u5b57\u7b26\u4e32\u5b57\u6bb5\u662f\u5426\u4e0d\u4e3a\u7a7a\u5b57\u7b26\u4e32\u3002\u4f8b\u5982\uff1a SELECT * FROM table_name WHERE column_name != &#8221;; \u767b\u5f55\u540e\u590d\u5236 \u9002\u7528\u60c5\u51b5 IS NOT NULL \u9002\u7528\u4e8e\u6240\u6709\u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ec\u6570\u5b57\u3001\u65e5\u671f\u548c\u5e03\u5c14\u503c\u3002 != &#8221; \u4ec5\u9002\u7528\u4e8e\u5b57\u7b26\u4e32\u5b57\u6bb5\u3002 \u54ea\u79cd\u65b9\u6cd5\u66f4\u597d\uff1f IS [&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-5882","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5882","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=5882"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5882\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5882"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5882"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5882"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}