{"id":41,"date":"2006-09-27T15:48:27","date_gmt":"2006-09-27T15:48:27","guid":{"rendered":"http:\/\/thenoyes.com\/littlenoise\/?p=41"},"modified":"2006-09-27T15:48:27","modified_gmt":"2006-09-27T15:48:27","slug":"empty-set-equality","status":"publish","type":"post","link":"https:\/\/thenoyes.com\/littlenoise\/?p=41","title":{"rendered":"Empty Set Equality"},"content":{"rendered":"<pre>SELECT 1 LIMIT 0;\r\nEmpty set (0.00 sec)\r\n\r\nSELECT 2 LIMIT 0;\r\nEmpty set (0.00 sec)\r\n\r\nSELECT NULL LIMIT 0;\r\nEmpty set (0.00 sec)<\/pre>\n<p>Exactly what I&#8217;d expect. So here&#8217;s the question:<\/p>\n<pre>SELECT '1 = 1' AS equality, (SELECT 1 LIMIT 0) = (SELECT 1 LIMIT 0) AS result\r\nUNION SELECT '1 = 2', (SELECT 1 LIMIT 0) = (SELECT 2 LIMIT 0)\r\nUNION SELECT '1 = NULL', (SELECT 1 LIMIT 0) = (SELECT NULL LIMIT 0);<\/pre>\n<p>What do you think? Are all empty sets created identical?<br \/>\n<spoiler 'Show Answer' 'Hide Answer'>MySQL says no.<\/p>\n<pre>+----------+--------+\r\n| equality | result |\r\n+----------+--------+\r\n| 1 = 1    |      1 |\r\n| 1 = 2    |      0 |\r\n| 1 = NULL |   NULL |\r\n+----------+--------+<\/pre>\n<p><\/spoiler><\/p>\n","protected":false},"excerpt":{"rendered":"<p>SELECT 1 LIMIT 0; Empty set (0.00 sec) SELECT 2 LIMIT 0; Empty set (0.00 sec) SELECT NULL LIMIT 0; Empty set (0.00 sec) Exactly what I&#8217;d expect. So here&#8217;s the question: SELECT &#8216;1 = 1&#8217; AS equality, (SELECT 1 LIMIT 0) = (SELECT 1 LIMIT 0) AS result UNION SELECT &#8216;1 = 2&#8217;, (SELECT [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[6],"tags":[],"class_list":["post-41","post","type-post","status-publish","format-standard","hentry","category-gotchas"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2IBF1-F","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts\/41","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=41"}],"version-history":[{"count":0,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts\/41\/revisions"}],"wp:attachment":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}