{"id":138,"date":"2016-03-20T00:09:11","date_gmt":"2016-03-20T00:09:11","guid":{"rendered":"http:\/\/hammod.com\/?p=138"},"modified":"2021-10-03T17:31:03","modified_gmt":"2021-10-03T17:31:03","slug":"three-value-logic","status":"publish","type":"post","link":"http:\/\/hammod.com\/?p=138","title":{"rendered":"Three value logic"},"content":{"rendered":"<p><a href=\"http:\/\/hammod.com\/wp-content\/uploads\/2016\/03\/three_value_logic.jpg\" rel=\"attachment wp-att-146\"><img loading=\"lazy\" class=\"wp-image-146 size-full aligncenter\" src=\"http:\/\/hammod.com\/wp-content\/uploads\/2016\/03\/three_value_logic.jpg\" alt=\"three_value_logic\" width=\"591\" height=\"269\" srcset=\"http:\/\/hammod.com\/wp-content\/uploads\/2016\/03\/three_value_logic.jpg 591w, http:\/\/hammod.com\/wp-content\/uploads\/2016\/03\/three_value_logic-300x137.jpg 300w\" sizes=\"(max-width: 591px) 100vw, 591px\" \/><\/a>In SQL, When a NULL is involved in a comparison operation, the result is considered to be UNKNOWN (it may be TRUE or it may be FALSE). Hence, SQL uses a three valued logic with values TRUE, FALSE, and UNKNOWN instead of the standard two-valued (Boolean) logic with values TRUE or FALSE. It is therefore necessary to define the results (or truth values) of three-valued logical expressions when the logical connectives AND, OR, and NOT are used.<\/p>\n<p>[table caption=&#8221;Three-Valued logic with AND&#8221; width=&#8221;350&#8243; colwidth=&#8221;100|50|50&#8243; colalign=&#8221;left|left|left|left&#8221;]<br \/>\n<span style=\"color: #ff0000;\">AND<\/span>,TRUE,FALSE,UNKNOWN,<br \/>\n<strong>TURE<\/strong>, T, F, UNK<br \/>\n<strong>FALSE<\/strong>, F,F,F<br \/>\n<strong>UNKOWN<\/strong>,UNK,F,UNK<br \/>\n[\/table]<\/p>\n<p style=\"text-align: left;\">[table caption=&#8221;Three-Valued logic with OR &#8221; width=&#8221;350&#8243; colwidth=&#8221;100|50|50&#8243; colalign=&#8221;left|left|left|left&#8221;]<br \/>\n<span style=\"color: #ff0000;\">OR <\/span>,TRUE,FALSE,UNKNOWN,<br \/>\n<strong>TURE<\/strong>, T, T,T<br \/>\n<strong>FALSE<\/strong>, T,F,UNK<br \/>\n<strong>UNKOWN<\/strong>,T,UNK,UNK<br \/>\n[\/table]<\/p>\n<p>[table caption=&#8221;Three-Valued logic with NOT&#8221; width=&#8221;150&#8243; colwidth=&#8221;100|50|50&#8243; colalign=&#8221;left|left&#8221;]<br \/>\n<span style=\"color: #ff0000;\">NOT <\/span>,<br \/>\n<strong>TURE<\/strong>, F<br \/>\n<strong>FALSE<\/strong>, T<br \/>\n<strong>UNKOWN<\/strong>,UNK<br \/>\n[\/table]<\/p>\n<p>Reference:<\/p>\n<p>Elmasri, R., &amp; Navathe, S. (2011). <i>Fundamentals of database systems<\/i>. Boston: Addison-Wesley.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In SQL, When a NULL is involved in a comparison operation, the result is considered to be UNKNOWN (it may be TRUE or it may be FALSE). Hence, SQL uses a three<a class=\"moretag\" href=\"http:\/\/hammod.com\/?p=138\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":146,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/hammod.com\/index.php?rest_route=\/wp\/v2\/posts\/138"}],"collection":[{"href":"http:\/\/hammod.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/hammod.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/hammod.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/hammod.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=138"}],"version-history":[{"count":28,"href":"http:\/\/hammod.com\/index.php?rest_route=\/wp\/v2\/posts\/138\/revisions"}],"predecessor-version":[{"id":229,"href":"http:\/\/hammod.com\/index.php?rest_route=\/wp\/v2\/posts\/138\/revisions\/229"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/hammod.com\/index.php?rest_route=\/wp\/v2\/media\/146"}],"wp:attachment":[{"href":"http:\/\/hammod.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/hammod.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=138"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/hammod.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}