{"id":354,"date":"2023-05-28T01:42:48","date_gmt":"2023-05-27T17:42:48","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=354"},"modified":"2023-05-28T01:42:48","modified_gmt":"2023-05-27T17:42:48","slug":"sql%e9%ab%98%e7%ba%a7%e7%af%87%ef%bd%9e%e8%81%94%e5%90%88%e6%9f%a5%e8%af%a2","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/mysql\/sql%e9%ab%98%e7%ba%a7%e7%af%87%ef%bd%9e%e8%81%94%e5%90%88%e6%9f%a5%e8%af%a2\/","title":{"rendered":"SQL\u9ad8\u7ea7\u7bc7\uff5e\u8054\u5408\u67e5\u8be2"},"content":{"rendered":"<div class=\"wxsyncmain\">\n<p style=\"box-sizing: border-box; margin-bottom: 20px; color: #222222; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; font-size: 18px; white-space: normal; background-color: #ffffff; text-indent: 2em; border: 0px initial initial;\" data-track=\"1\"><span style=\"box-sizing: border-box; color: #374151; border: 0px initial initial;\">SQL\u7684\u8054\u5408\u67e5\u8be2\uff08Union Query\uff09\u662f\u4e00\u79cd\u5c06\u4e24\u4e2a\u6216\u591a\u4e2aSELECT\u8bed\u53e5\u7684\u7ed3\u679c\u96c6\u5408\u5e76\u5728\u4e00\u8d77\u7684\u65b9\u6cd5\u3002\u5b83\u53ef\u4ee5\u5c06\u591a\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\u5408\u5e76\u6210\u4e00\u4e2a\u5927\u7684\u7ed3\u679c\u96c6\uff0c\u8fd9\u4e2a\u5927\u7684\u7ed3\u679c\u96c6\u4e2d\u5305\u542b\u4e86\u539f\u59cb\u67e5\u8be2\u7684\u6240\u6709\u6570\u636e\u884c\u3002\u8fd9\u4e2a\u7279\u6027\u4f7f\u5f97\u8054\u5408\u67e5\u8be2\u6210\u4e3a\u4e86SQL\u8bed\u8a00\u4e2d\u975e\u5e38\u5f3a\u5927\u548c\u5e38\u7528\u7684\u529f\u80fd\u4e4b\u4e00\u3002<\/span><\/p>\n<p style=\"box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; color: #222222; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; font-size: 18px; white-space: normal; background-color: #ffffff; border: 0px initial initial;\" data-track=\"2\"><span style=\"box-sizing: border-box; color: #374151; border: 0px initial initial;\">\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5173\u4e8eSQL\u8054\u5408\u67e5\u8be2\u7684\u8be6\u7ec6\u4fe1\u606f\uff1a<\/span><\/p>\n<h1 style=\"box-sizing: border-box; font-size: 1.056em; margin-top: 20px; margin-bottom: 20px; font-weight: bold; line-height: 1.579; color: #000000; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; white-space: normal; background-color: #ffffff; border: 0px initial initial;\" data-track=\"29\">\u57fa\u672c\u8bed\u6cd5<\/h1>\n<p style=\"box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; color: #222222; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; font-size: 18px; white-space: normal; background-color: #ffffff; border: 0px initial initial;\" data-track=\"4\"><span style=\"box-sizing: border-box; color: #374151; border: 0px initial initial;\">SQL\u8054\u5408\u67e5\u8be2\u7684\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a<\/span><\/p>\n<pre style=\"box-sizing: border-box; font-family: Monaco; font-size: 18px; margin-top: 20px; margin-bottom: 20px; padding: 15px; background: #fafafa; white-space: pre-wrap; word-break: break-all; overflow-x: auto; border-radius: 3px; text-align: left; color: #222222; box-shadow: rgba(216, 216, 216, 0.5) 0px 0px 0px 1px inset; border: 0px initial initial;\"><code style=\"white-space: pre-wrap; box-sizing: border-box; font-family: inherit; font-size: 14px; overflow-wrap: normal; word-break: normal; overflow-x: auto; line-height: 24px; border: 0px initial initial;\"><span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">SELECT<\/span> column_name(s) <span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">FROM<\/span> table_name1\n<span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">UNION<\/span>\n<span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">SELECT<\/span> column_name(s) <span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">FROM<\/span> table_name2;\n<\/code><\/pre>\n<p style=\"box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; color: #222222; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; font-size: 18px; white-space: normal; background-color: #ffffff; border: 0px initial initial;\" data-track=\"6\"><span style=\"box-sizing: border-box; color: #374151; border: 0px initial initial;\">\u5176\u4e2d\uff0ctable_name1 \u548c table_name2 \u662f\u8981\u67e5\u8be2\u7684\u8868\u540d\uff0ccolumn_name(s) \u662f\u8981\u8fd4\u56de\u7684\u5217\u7684\u540d\u79f0\uff0cUNION \u5173\u952e\u5b57\u5c06\u4e24\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\u96c6\u5408\u5e76\u5728\u4e00\u8d77\u3002<\/span><\/p>\n<h1 style=\"box-sizing: border-box; font-size: 1.056em; margin-top: 20px; margin-bottom: 20px; font-weight: bold; line-height: 1.579; color: #000000; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; white-space: normal; background-color: #ffffff; border: 0px initial initial;\">\u67e5\u8be2\u7ed3\u679c\u96c6\u7684\u5217\u6570\u548c\u5217\u7c7b\u578b\u5fc5\u987b\u76f8\u540c<\/h1>\n<p style=\"box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; color: #222222; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; font-size: 18px; white-space: normal; background-color: #ffffff; border: 0px initial initial;\" data-track=\"8\"><span style=\"box-sizing: border-box; color: #374151; border: 0px initial initial;\">\u5728\u8054\u5408\u67e5\u8be2\u4e2d\uff0c\u4e24\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\u96c6\u7684\u5217\u6570\u548c\u5217\u7c7b\u578b\u5fc5\u987b\u76f8\u540c\uff0c\u5426\u5219\u4f1a\u5bfc\u81f4\u9519\u8bef\u3002\u5982\u679c\u4e24\u4e2a\u67e5\u8be2\u7684\u5217\u6570\u4e0d\u540c\uff0c\u5219\u9700\u8981\u901a\u8fc7\u6dfb\u52a0\u7a7a\u5217\u6765\u5bf9\u9f50\u7ed3\u679c\u96c6\u3002\u5982\u679c\u4e24\u4e2a\u67e5\u8be2\u7684\u5217\u7c7b\u578b\u4e0d\u540c\uff0c\u5219\u9700\u8981\u901a\u8fc7\u4f7f\u7528 CAST \u6216 CONVERT \u51fd\u6570\u6765\u5f3a\u5236\u8f6c\u6362\u7c7b\u578b\u3002<\/span><\/p>\n<ol class=\"list-paddingleft-1\" style=\"margin: 20px 30px; counter-reset: ol_list 0; color: #222222; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; font-size: 18px; white-space: normal; background-color: #ffffff; border: 0px initial initial;\" start=\"3\">\n<li style=\"box-sizing: border-box; list-style: none; border: 0px initial initial;\"><span style=\"box-sizing: border-box; color: #374151; border: 0px initial initial;\">UNION \u548c UNION ALL \u7684\u533a\u522b<\/span><\/li>\n<\/ol>\n<p style=\"box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; color: #222222; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; font-size: 18px; white-space: normal; background-color: #ffffff; border: 0px initial initial;\" data-track=\"10\"><span style=\"box-sizing: border-box; color: #374151; border: 0px initial initial;\">UNION \u548c UNION ALL \u90fd\u53ef\u4ee5\u7528\u6765\u5408\u5e76\u67e5\u8be2\u7ed3\u679c\uff0c\u4f46\u5b83\u4eec\u4e4b\u95f4\u6709\u4e00\u4e2a\u91cd\u8981\u7684\u533a\u522b\uff1aUNION \u4f1a\u53bb\u91cd\uff0c\u800c UNION ALL \u4e0d\u4f1a\u3002<\/span><\/p>\n<p style=\"box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; color: #222222; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; font-size: 18px; white-space: normal; background-color: #ffffff; border: 0px initial initial;\" data-track=\"11\"><span style=\"box-sizing: border-box; color: #374151; border: 0px initial initial;\">\u4f8b\u5982\uff0c\u5982\u679c\u67e5\u8be2\u4e24\u4e2a\u8868\u4e2d\u7684\u6240\u6709\u5458\u5de5\u59d3\u540d\uff0c\u4f7f\u7528\u4ee5\u4e0b\u67e5\u8be2\uff1a<\/span><\/p>\n<pre style=\"box-sizing: border-box; font-family: Monaco; font-size: 18px; margin-top: 20px; margin-bottom: 20px; padding: 15px; background: #fafafa; white-space: pre-wrap; word-break: break-all; overflow-x: auto; border-radius: 3px; text-align: left; color: #222222; box-shadow: rgba(216, 216, 216, 0.5) 0px 0px 0px 1px inset; border: 0px initial initial;\"><code style=\"white-space: pre-wrap; box-sizing: border-box; font-family: inherit; font-size: 14px; overflow-wrap: normal; word-break: normal; overflow-x: auto; line-height: 24px; border: 0px initial initial;\"><span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">SELECT<\/span> <span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">name<\/span> <span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">FROM<\/span> table1\n<span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">UNION<\/span>\n<span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">SELECT<\/span> <span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">name<\/span> <span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">FROM<\/span> table2;\n<\/code><\/pre>\n<p style=\"box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; color: #222222; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; font-size: 18px; white-space: normal; background-color: #ffffff; border: 0px initial initial;\" data-track=\"13\"><span style=\"box-sizing: border-box; color: #374151; border: 0px initial initial;\">\u5982\u679c\u4e24\u4e2a\u8868\u4e2d\u6709\u76f8\u540c\u7684\u5458\u5de5\u59d3\u540d\uff0c\u5219\u53ea\u4f1a\u8fd4\u56de\u4e00\u4e2a\u59d3\u540d\u3002\u4f46\u662f\uff0c\u5982\u679c\u4f7f\u7528 UNION ALL \u66ff\u6362 UNION\uff0c\u5219\u4f1a\u8fd4\u56de\u6240\u6709\u7684\u5458\u5de5\u59d3\u540d\uff0c\u5305\u62ec\u91cd\u590d\u7684\u59d3\u540d\u3002<\/span><\/p>\n<h1 style=\"box-sizing: border-box; font-size: 1.056em; margin-top: 20px; margin-bottom: 20px; font-weight: bold; line-height: 1.579; color: #000000; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; white-space: normal; background-color: #ffffff; border: 0px initial initial;\">UNION \u7684\u6027\u80fd<\/h1>\n<p style=\"box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; color: #222222; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; font-size: 18px; white-space: normal; background-color: #ffffff; border: 0px initial initial;\" data-track=\"15\"><span style=\"box-sizing: border-box; color: #374151; border: 0px initial initial;\">\u8054\u5408\u67e5\u8be2\u53ef\u4ee5\u5728\u6027\u80fd\u65b9\u9762\u4ea7\u751f\u4e00\u4e9b\u95ee\u9898\uff0c\u7279\u522b\u662f\u5728\u5904\u7406\u5927\u578b\u6570\u636e\u96c6\u65f6\u3002\u8fd9\u662f\u56e0\u4e3a UNION \u67e5\u8be2\u9700\u8981\u5bf9\u4e24\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\u96c6\u8fdb\u884c\u6392\u5e8f\u548c\u53bb\u91cd\uff0c\u8fd9\u53ef\u80fd\u9700\u8981\u5927\u91cf\u7684 CPU \u548c\u5185\u5b58\u8d44\u6e90\u3002\u4e3a\u4e86\u63d0\u9ad8\u6027\u80fd\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/span><\/p>\n<ul class=\"list-paddingleft-1\" style=\"margin: 20px 30px; counter-reset: ul_list 0; color: #222222; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; font-size: 18px; white-space: normal; background-color: #ffffff; border: 0px initial initial;\">\n<li style=\"box-sizing: border-box; list-style: none; border: 0px initial initial;\"><span style=\"box-sizing: border-box; color: #374151; border: 0px initial initial;\">\u5c3d\u53ef\u80fd\u5730\u7f29\u5c0f\u6bcf\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\u96c6\uff0c\u4f8b\u5982\u4f7f\u7528 WHERE \u5b50\u53e5\u9650\u5236\u8fd4\u56de\u7684\u6570\u636e\u884c\u3002<\/span><\/li>\n<li style=\"box-sizing: border-box; list-style: none; border: 0px initial initial;\"><span style=\"box-sizing: border-box; color: #374151; border: 0px initial initial;\">\u5bf9\u4e8e\u4e0d\u9700\u8981\u53bb\u91cd\u7684\u67e5\u8be2\uff0c\u4f7f\u7528 UNION ALL \u4ee3\u66ff UNION\u3002<\/span><\/li>\n<li style=\"box-sizing: border-box; list-style: none; border: 0px initial initial;\"><span style=\"box-sizing: border-box; color: #374151; border: 0px initial initial;\">\u786e\u4fdd\u8868\u4e0a\u6709\u9002\u5f53\u7684\u7d22\u5f15\uff0c\u4ee5\u4fbf\u4f18\u5316\u67e5\u8be2\u6027\u80fd\u3002<\/span><\/li>\n<\/ul>\n<h1 style=\"box-sizing: border-box; font-size: 1.056em; margin-top: 20px; margin-bottom: 20px; font-weight: bold; line-height: 1.579; color: #000000; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; white-space: normal; background-color: #ffffff; border: 0px initial initial;\">UNION \u7684\u5d4c\u5957<\/h1>\n<p style=\"box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; color: #222222; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; font-size: 18px; white-space: normal; background-color: #ffffff; border: 0px initial initial;\" data-track=\"20\"><span style=\"box-sizing: border-box; color: #374151; border: 0px initial initial;\">\u53ef\u4ee5\u5c06\u591a\u4e2a\u8054\u5408\u67e5\u8be2\u5d4c\u5957\u5728\u4e00\u8d77\uff0c\u4ee5\u521b\u5efa\u66f4\u590d\u6742\u7684\u67e5\u8be2\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b\u67e5\u8be2\u5c06\u8fd4\u56de\u6240\u6709\u7684\u4ea7\u54c1\u540d\u79f0\u548c\u4ef7\u683c\uff0c\u6309\u4ef7\u683c\u6392\u5e8f\uff0c\u5e76\u4e14\u4ec5\u8fd4\u56de\u524d5\u4e2a\u7ed3\u679c\uff1a<\/span><\/p>\n<pre style=\"box-sizing: border-box; font-family: Monaco; font-size: 18px; margin-top: 20px; margin-bottom: 20px; padding: 15px; background: #fafafa; white-space: pre-wrap; word-break: break-all; overflow-x: auto; border-radius: 3px; text-align: left; color: #222222; box-shadow: rgba(216, 216, 216, 0.5) 0px 0px 0px 1px inset; border: 0px initial initial;\"><code style=\"white-space: pre-wrap; box-sizing: border-box; font-family: inherit; font-size: 14px; overflow-wrap: normal; word-break: normal; overflow-x: auto; line-height: 24px; border: 0px initial initial;\"><span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">SELECT<\/span> <span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">name<\/span>, price <span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">FROM<\/span> (\n  <span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">SELECT<\/span> <span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">name<\/span>, price <span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">FROM<\/span> products1\n  <span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">UNION<\/span>\n  <span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">SELECT<\/span> <span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">name<\/span>, price <span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">FROM<\/span> products2\n) <span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">AS<\/span> combined\n<span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">ORDER<\/span> <span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">BY<\/span> price <span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">DESC<\/span>\n<span style=\"box-sizing: border-box; color: #114ba6; border: 0px initial initial;\">LIMIT<\/span> <span style=\"box-sizing: border-box; color: #a82e2e; border: 0px initial initial;\">5<\/span>;\n<\/code><\/pre>\n<p style=\"box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; color: #222222; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; font-size: 18px; white-space: normal; background-color: #ffffff; border: 0px initial initial;\" data-track=\"22\"><span style=\"box-sizing: border-box; color: #374151; border: 0px initial initial;\">\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u4e24\u4e2a SELECT \u8bed\u53e5\u7684\u7ed3\u679c\u96c6\u88ab\u5408\u5e76\u6210\u4e00\u4e2a\u7ed3\u679c\u96c6\uff0c\u5e76\u901a\u8fc7\u5d4c\u5957\u5728\u4e00\u4e2a\u5b50\u67e5\u8be2\u4e2d\u6765\u8fdb\u884c\u6392\u5e8f\u548c\u7b5b\u9009\u3002<\/span><\/p>\n<p style=\"box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; color: #222222; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; font-size: 18px; white-space: normal; background-color: #ffffff; border: 0px initial initial;\" data-track=\"23\"><span style=\"box-sizing: border-box; color: #374151; border: 0px initial initial;\">\u603b\u4e4b\uff0cSQL\u8054\u5408\u67e5\u8be2\u662f\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u548c\u5f3a\u5927\u7684\u529f\u80fd\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u4ece\u591a\u4e2a\u8868\u4e2d\u68c0\u7d22\u548c\u7ec4\u5408\u6570\u636e\u3002\u5728\u4f7f\u7528\u8054\u5408\u67e5\u8be2\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4e24\u4e2a\u67e5\u8be2\u7684\u5217\u6570\u548c\u5217\u7c7b\u578b\u5fc5\u987b\u76f8\u540c\uff0c\u540c\u65f6\u4e5f\u9700\u8981\u8003\u8651\u6027\u80fd\u65b9\u9762\u7684\u95ee\u9898\u3002\u4e3a\u4e86\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\uff0c\u53ef\u4ee5\u9650\u5236\u6bcf\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\u96c6\u5927\u5c0f\uff0c\u4f7f\u7528\u9002\u5f53\u7684\u7d22\u5f15\uff0c\u4ee5\u53ca\u8003\u8651\u4f7f\u7528 UNION ALL \u66ff\u6362 UNION \u6765\u907f\u514d\u53bb\u91cd\u7684\u5f00\u9500\u3002<\/span><\/p>\n<p style=\"box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; color: #222222; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; font-size: 18px; white-space: normal; background-color: #ffffff; border: 0px initial initial;\" data-track=\"24\"><span style=\"box-sizing: border-box; color: #374151; border: 0px initial initial;\">\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u8054\u5408\u67e5\u8be2\u53ef\u4ee5\u7528\u4e8e\u591a\u79cd\u573a\u666f\uff0c\u4f8b\u5982\u5c06\u591a\u4e2a\u8868\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u5408\u5e76\u3001\u67e5\u8be2\u591a\u4e2a\u8868\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u6bd4\u8f83\u6216\u8005\u8ba1\u7b97\u6c47\u603b\u7ed3\u679c\u7b49\u3002\u540c\u65f6\uff0c\u8054\u5408\u67e5\u8be2\u4e5f\u53ef\u4ee5\u5d4c\u5957\u5728\u5176\u4ed6\u67e5\u8be2\u4e2d\uff0c\u4ee5\u521b\u5efa\u66f4\u590d\u6742\u7684\u67e5\u8be2\u3002<\/span><\/p>\n<p style=\"box-sizing: border-box; margin-top: 20px; margin-bottom: 20px; color: #222222; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; font-size: 18px; white-space: normal; background-color: #ffffff; border: 0px initial initial;\" data-track=\"25\"><span style=\"box-sizing: border-box; color: #374151; border: 0px initial initial;\">\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8054\u5408\u67e5\u8be2\u53ef\u80fd\u4f1a\u4f7f\u5f97\u67e5\u8be2\u8bed\u53e5\u7684\u590d\u6742\u5ea6\u589e\u52a0\uff0c\u5bfc\u81f4\u96be\u4ee5\u7ef4\u62a4\u548c\u7406\u89e3\u3002\u56e0\u6b64\uff0c\u5728\u4f7f\u7528\u8054\u5408\u67e5\u8be2\u65f6\uff0c\u9700\u8981\u6839\u636e\u5177\u4f53\u60c5\u51b5\u6765\u9009\u62e9\u4f7f\u7528\uff0c\u5e76\u786e\u4fdd\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002<\/span><\/p>\n<p style=\"box-sizing: border-box; margin-top: 20px; color: #222222; font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, sans-serif; font-size: 18px; white-space: normal; background-color: #ffffff; margin-bottom: 0px !important; border: 0px initial initial;\" data-track=\"26\">\n<p style=\"display: none;\">\n<blockquote><p>\u672c\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e\u5fae\u4fe1\u516c\u4f17\u53f7: IT\u594b\u6597\u7684\u9752\u5e74<\/p><\/blockquote>\n<\/div>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>SQL\u7684\u8054\u5408\u67e5\u8be2\uff08Union Query\uff09\u662f\u4e00\u79cd\u5c06\u4e24\u4e2a\u6216\u591a\u4e2aSELECT\u8bed\u53e5\u7684\u7ed3\u679c\u96c6\u5408\u5e76\u5728\u4e00\u8d77\u7684\u65b9\u6cd5\u3002\u5b83\u53ef\u4ee5\u5c06\u591a\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\u5408\u5e76\u6210 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":352,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[3],"tags":[],"class_list":["post-354","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528004800402-150x150.jpeg","content_first_image":null,"post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528004800402-300x128.jpeg","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528004800402.jpeg","post_frist_image":null,"post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528004800402-300x128.jpeg","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528004800402.jpeg","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528004800402.jpeg","post_all_images":[],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"MySQL","post_date":"2023-05-27","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230519082947553.jpg","avatarurls":[],"related_posts":null,"pageviews":262,"next_post_id":326,"next_post_title":"45\u4e2a\u6570\u636e\u5e93SQL\u6027\u80fd\u4f18\u5316\u65b9\u6848\uff0cSQL\u6027\u80fd\u63d0\u5347\u597d\u51e0\u500d\uff01","previous_post_id":543,"previous_post_title":"\u4e00\u5343\u884c MySQL \u5b66\u4e60\u7b14\u8bb0","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=354"}],"version-history":[{"count":0,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/354\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media\/352"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}