\u5047\u8bbe\u6709\u4e0b\u9762\u4e24\u4e2a\u8868\uff0c\uff081\uff09COMPANY \u8868\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n
\r\nsqlite> select * from COMPANY;\r\nID NAME AGE ADDRESS SALARY\r\n---------- -------------------- ---------- ---------- ----------\r\n1 Paul 32 California 20000.0\r\n2 Allen 25 Texas 15000.0\r\n3 Teddy 23 Norway 20000.0\r\n4 Mark 25 Rich-Mond 65000.0\r\n5 David 27 Texas 85000.0\r\n6 Kim 22 South-Hall 45000.0\r\n7 James 24 Houston 10000.0<\/pre>\n\uff082\uff09\u53e6\u4e00\u4e2a\u8868\u662f DEPARTMENT\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n
\r\nID DEPT EMP_ID\r\n---------- -------------------- ----------\r\n1 IT Billing 1\r\n2 Engineering 2\r\n3 Finance 7\r\n4 Engineering 3\r\n5 Finance 4\r\n6 Engineering 5\r\n7 Finance 6<\/pre>\n\u73b0\u5728\uff0c\u8ba9\u6211\u4eec\u4f7f\u7528 SELECT \u8bed\u53e5\u53ca UNION \u5b50\u53e5\u6765\u8fde\u63a5\u4e24\u4e2a\u8868\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n
\r\nsqlite> SELECT EMP_ID, NAME, DEPT FROM COMPANY INNER JOIN DEPARTMENT\r\n ON COMPANY.ID = DEPARTMENT.EMP_ID\r\n UNION\r\n SELECT EMP_ID, NAME, DEPT FROM COMPANY LEFT OUTER JOIN DEPARTMENT\r\n ON COMPANY.ID = DEPARTMENT.EMP_ID;<\/pre>\n\u8fd9\u5c06\u4ea7\u751f\u4ee5\u4e0b\u7ed3\u679c\uff1a<\/p>\n
\r\nEMP_ID NAME DEPT\r\n---------- -------------------- ----------\r\n1 Paul IT Billing\r\n2 Allen Engineerin\r\n3 Teddy Engineerin\r\n4 Mark Finance\r\n5 David Engineerin\r\n6 Kim Finance\r\n7 James Finance<\/pre>\nUNION ALL \u5b50\u53e5<\/strong><\/div>\nUNION ALL \u8fd0\u7b97\u7b26\u7528\u4e8e\u7ed3\u5408\u4e24\u4e2a SELECT \u8bed\u53e5\u7684\u7ed3\u679c\uff0c\u5305\u62ec\u91cd\u590d\u884c\u3002<\/p>\n
\u9002\u7528\u4e8e UNION \u7684\u89c4\u5219\u540c\u6837\u9002\u7528\u4e8e UNION ALL \u8fd0\u7b97\u7b26\u3002<\/p>\n
\u8bed\u6cd5<\/strong><\/span><\/div>\nUNION ALL \u7684\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n
\r\nSELECT column1 [, column2 ]\r\nFROM table1 [, table2 ]\r\n[WHERE condition]\r\n\r\nUNION ALL\r\n\r\nSELECT column1 [, column2 ]\r\nFROM table1 [, table2 ]\r\n[WHERE condition]<\/pre>\n\u8fd9\u91cc\u7ed9\u5b9a\u7684\u6761\u4ef6\u6839\u636e\u9700\u8981\u53ef\u4ee5\u662f\u4efb\u4f55\u8868\u8fbe\u5f0f\u3002<\/p>\n
\u5b9e\u4f8b<\/strong><\/span><\/div>\n\u73b0\u5728\uff0c\u8ba9\u6211\u4eec\u4f7f\u7528 SELECT \u8bed\u53e5\u53ca UNION ALL \u5b50\u53e5\u6765\u8fde\u63a5\u4e24\u4e2a\u8868\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n
\r\nsqlite> SELECT EMP_ID, NAME, DEPT FROM COMPANY INNER JOIN DEPARTMENT\r\n ON COMPANY.ID = DEPARTMENT.EMP_ID\r\n UNION ALL\r\n SELECT EMP_ID, NAME, DEPT FROM COMPANY LEFT OUTER JOIN DEPARTMENT\r\n ON COMPANY.ID = DEPARTMENT.EMP_ID;<\/pre>\n\u8fd9\u5c06\u4ea7\u751f\u4ee5\u4e0b\u7ed3\u679c\uff1a<\/p>\n
\r\nEMP_ID NAME DEPT\r\n---------- -------------------- ----------\r\n1 Paul IT Billing\r\n2 Allen Engineerin\r\n3 Teddy Engineerin\r\n4 Mark Finance\r\n5 David Engineerin\r\n6 Kim Finance\r\n7 James Finance\r\n1 Paul IT Billing\r\n2 Allen Engineerin\r\n3 Teddy Engineerin\r\n4 Mark Finance\r\n5 David Engineerin\r\n6 Kim Finance\r\n7 James Finance<\/pre>\n","protected":false},"excerpt":{"rendered":"UNION \u7684\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a SELECT column1 [, column2 ] FROM table1 […]<\/p>\n","protected":false},"author":321,"featured_media":199408,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-199452","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/199452","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/321"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=199452"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/199452\/revisions"}],"predecessor-version":[{"id":199457,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/199452\/revisions\/199457"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/199408"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=199452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=199452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=199452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}