{"id":3,"date":"2006-06-16T16:06:22","date_gmt":"2006-06-16T16:06:22","guid":{"rendered":"http:\/\/thenoyes.com\/littlenoise\/?p=3"},"modified":"2006-06-16T20:54:32","modified_gmt":"2006-06-16T20:54:32","slug":"unified-rows","status":"publish","type":"post","link":"https:\/\/thenoyes.com\/littlenoise\/?p=3","title":{"rendered":"Unified Rows"},"content":{"rendered":"<p>Here are a couple table definitions:<\/p>\n<p><code>CREATE TABLE `users1` (<br \/>\n`name` varchar(10) default NULL,<br \/>\n`birthday` date default NULL<br \/>\n);<\/code><\/p>\n<p><code>CREATE TABLE `users2` (<br \/>\n`name` varchar(10) default NULL,<br \/>\n`birthday` date default NULL<br \/>\n);<\/code><\/p>\n<p>After inserting some data, we get the following row counts:<\/p>\n<p><code>SELECT COUNT(*) FROM users1;<br \/>\n+----------+<br \/>\n| COUNT(*) |<br \/>\n+----------+<br \/>\n|       15 |<br \/>\n+----------+<\/code><\/p>\n<p><code>SELECT COUNT(*) FROM users2;<br \/>\n+----------+<br \/>\n| COUNT(*) |<br \/>\n+----------+<br \/>\n|       12 |<br \/>\n+----------+<br \/>\n<\/code><\/p>\n<p>Now, for this query:<\/p>\n<p><code>SELECT * FROM users1 UNION SELECT * FROM users2;<\/code><\/p>\n<p>How many rows will be in the result set? (Choose the best answer)<\/p>\n<p>a) Exactly 27<br \/>\nb) At least 12<br \/>\nc) At least 15<br \/>\nd) Between 1 and 27<br \/>\ne) Zero or more<\/p>\n<p><spoiler 'Show Answer' 'Hide Answer'>d) Between 1 and 27. Default behavior for UNION is DISTINCT. If all 27 rows in the two tables are identical, there will be only 1 row in the result. If all are unique, there will be 27 rows.<\/spoiler><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here are a couple table definitions: CREATE TABLE `users1` ( `name` varchar(10) default NULL, `birthday` date default NULL ); CREATE TABLE `users2` ( `name` varchar(10) default NULL, `birthday` date default NULL ); After inserting some data, we get the following row counts: SELECT COUNT(*) FROM users1; +&#8212;&#8212;&#8212;-+ | COUNT(*) | +&#8212;&#8212;&#8212;-+ | 15 | +&#8212;&#8212;&#8212;-+ [&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-3","post","type-post","status-publish","format-standard","hentry","category-gotchas"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2IBF1-3","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts\/3","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=3"}],"version-history":[{"count":0,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts\/3\/revisions"}],"wp:attachment":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}