{"id":200805,"date":"2025-05-06T09:32:46","date_gmt":"2025-05-06T01:32:46","guid":{"rendered":"https:\/\/server.hk\/cnblog\/200805\/"},"modified":"2025-05-06T09:32:46","modified_gmt":"2025-05-06T01:32:46","slug":"mysql-%e4%b8%ad-is-true-%e5%92%8c-true-%e6%9f%a5%e8%af%a2%e7%bb%93%e6%9e%9c%e4%b8%8d%e4%b8%80%e8%87%b4%e7%9a%84%e5%8e%9f%e5%9b%a0%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/200805\/","title":{"rendered":"MySQL \u4e2d IS TRUE \u548c =True \u67e5\u8be2\u7ed3\u679c\u4e0d\u4e00\u81f4\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>MySQL \u4e2d IS TRUE \u548c =True \u67e5\u8be2\u7ed3\u679c\u4e0d\u4e00\u81f4\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f<\/h1>\n<p>\u6765\u5230\u4e3b\u673a\u5b9d\u8d1d\u7684\u5927\u5bb6\uff0c\u76f8\u4fe1\u90fd\u662f\u7f16\u7a0b\u5b66\u4e60\u7231\u597d\u8005\uff0c\u5e0c\u671b\u5728\u8fd9\u91cc\u5b66\u4e60\u6570\u636e\u5e93\u76f8\u5173\u7f16\u7a0b\u77e5\u8bc6\u3002\u4e0b\u9762\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u5e26\u5927\u5bb6\u804a\u804a\u300aMySQL \u4e2d IS TRUE \u548c =True \u67e5\u8be2\u7ed3\u679c\u4e0d\u4e00\u81f4\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f\u300b\uff0c\u4ecb\u7ecd\u4e00\u4e0b\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u52a9\u529b\u5b9e\u6218\u5f00\u53d1\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241115\/1731658716673703dccd397.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>mysql \u4e2d is true \u548c =true \u7ed3\u679c\u4e0d\u4e00\u81f4\u7684\u539f\u56e0<\/strong><\/p>\n<p>\u5728 mysql \u4e2d\u67e5\u8be2\u6570\u636e\u65f6\uff0c\u4f7f\u7528 is true \u548c =true \u4f5c\u4e3a\u6761\u4ef6\u4f1a\u5bfc\u81f4\u4e0d\u540c\u7684\u7ed3\u679c\u3002\u8fd9\u662f\u56e0\u4e3a\u8fd9\u4e24\u4e2a\u64cd\u4f5c\u5177\u6709\u4e0d\u540c\u7684\u8bed\u4e49\uff1a<\/p>\n<ul>\n<li><strong>=<\/strong> \u6267\u884c\u7684\u662f\u6570\u503c\u6bd4\u8f83\u3002true \u5728 mysql \u4e2d\u8868\u793a\u4e3a 1\uff0c\u4f46 is_deleted \u5217\u662f\u4e00\u4e2a tinyint(1) \u7c7b\u578b\uff0c\u5b83\u7684\u53d6\u503c\u8303\u56f4\u4e3a 0-255\u3002\u56e0\u6b64\uff0c=true \u5b9e\u9645\u4e0a\u662f\u5c06 is_deleted \u4e0e 1 \u8fdb\u884c\u6bd4\u8f83\u3002<\/li>\n<li><strong>is true<\/strong> \u6267\u884c\u7684\u662f\u771f\u5047\u5224\u65ad\u3002\u5728 mysql \u4e2d\uff0c\u975e\u96f6\u503c\u90fd\u8868\u793a true\uff0c\u800c 0 \u8868\u793a false\u3002\u56e0\u6b64\uff0cis true \u5c06 is_deleted \u4e3a\u975e\u96f6\uff08\u5373\u4e0d\u7b49\u4e8e 0\uff09\u7684\u8bb0\u5f55\u89c6\u4e3a true\u3002<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<p>\u5df2\u77e5\u8868\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n<pre>create table user (\n  id int not null auto_increment,\n  is_deleted tinyint(1) not null default 0,\n  primary key (id)\n);<\/pre>\n<p>\u63d2\u5165\u7684\u793a\u4f8b\u6570\u636e\uff1a<\/p>\n<pre>insert into user (is_deleted) values (127);\ninsert into user (is_deleted) values (0);<\/pre>\n<p><strong>\u67e5\u8be2\u7ed3\u679c<\/strong><\/p>\n<p>\u6267\u884c\u4ee5\u4e0b\u67e5\u8be2\u8bed\u53e5\uff1a<\/p>\n<pre>select * from `user` where is_deleted is true;<\/pre>\n<p>\u7ed3\u679c\uff1a<\/p>\n<pre>+----+------------+\n| id  | is_deleted |\n+----+------------+\n| 1   | 127        |\n+----+------------+<\/pre>\n<p>\u6267\u884c\u4ee5\u4e0b\u67e5\u8be2\u8bed\u53e5\uff1a<\/p>\n<pre>select * from `user` where is_deleted = true;<\/pre>\n<p>\u7ed3\u679c\uff1a<\/p>\n<pre>\u7a7a\u96c6<\/pre>\n<p>\u53ef\u89c1\uff0c\u4f7f\u7528 is true \u67e5\u8be2\u5230\u4e86 is_deleted \u4e3a 127\uff08\u975e 0\uff09\u7684\u8bb0\u5f55\uff0c\u800c\u4f7f\u7528 =true \u672a\u67e5\u8be2\u5230\u4efb\u4f55\u8bb0\u5f55\u3002<\/p>\n<p>\u4eca\u5929\u5173\u4e8e\u300aMySQL \u4e2d IS TRUE \u548c =True \u67e5\u8be2\u7ed3\u679c\u4e0d\u4e00\u81f4\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f\u300b\u7684\u5185\u5bb9\u5c31\u4ecb\u7ecd\u5230\u8fd9\u91cc\u4e86\uff0c\u662f\u4e0d\u662f\u5b66\u8d77\u6765\u4e00\u76ee\u4e86\u7136\uff01\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u5185\u5bb9\u8bf7\u5173\u6ce8\u4e3b\u673a\u5b9d\u8d1d\u516c\u4f17\u53f7\uff01<\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>MySQL \u4e2d IS TRUE &#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-200805","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200805","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=200805"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200805\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=200805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=200805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=200805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}