{"id":625,"date":"2010-10-01T08:30:18","date_gmt":"2010-10-01T08:30:18","guid":{"rendered":"http:\/\/enjoyasp.net\/?p=625"},"modified":"2010-10-01T08:30:18","modified_gmt":"2010-10-01T08:30:18","slug":"sql%e5%af%b9%e5%8f%96%e5%87%ba%e7%9a%84%e4%b8%80%e8%a1%8c%e6%95%b0%e6%8d%ae%e6%9f%90%e4%ba%9b%e5%ad%97%e6%ae%b5%e8%bf%9b%e8%a1%8c%e5%86%8d%e6%ac%a1%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/enjoyasp.net\/index.php\/2010\/10\/01\/sql%e5%af%b9%e5%8f%96%e5%87%ba%e7%9a%84%e4%b8%80%e8%a1%8c%e6%95%b0%e6%8d%ae%e6%9f%90%e4%ba%9b%e5%ad%97%e6%ae%b5%e8%bf%9b%e8%a1%8c%e5%86%8d%e6%ac%a1%e6%93%8d%e4%bd%9c\/","title":{"rendered":"sql:\u5bf9\u53d6\u51fa\u7684\u4e00\u884c\u6570\u636e\u67d0\u4e9b\u5b57\u6bb5\u8fdb\u884c\u518d\u6b21\u64cd\u4f5c"},"content":{"rendered":"<pre lang=\"tsql\">\r\n\u4e3b\u8981\u662f\u4e00\u884c\u7684\u6570\u636e\u67d0\u4e9b\u5b57\u6bb5\u6574\u6210\u4e00\u4e2atable,\u5bf9\u6b64table\u8fdb\u884c\u64cd\u4f5c\u5373\u53ef\r\n\u57fa\u7840\uff1aselect *, (select orderno) as new from bdorder , \u53ef\u591a\u6b21\u7528select\u64cd\u4f5c\u5b57\u6bb5\r\n\u6269\u5c55\uff1a\u53ef\u591a\u6b21\u7528select \u53d6\u51fa\u6570\u636e\uff0cunion\u6210\u4e00\u4e2atable \u5904\u7406\r\n\u4e3e\u4f8b\uff1a\u53d6\u51fa\u4e00\u884c\u4e2d\u6700\u5927\u7684\u503c\r\n  \r\nIF NOT OBJECT_ID('[tb]') IS NULL\r\n    DROP TABLE [tb]\r\nGO\r\nCREATE TABLE [tb](\r\na SMALLINT,\r\nb SMALLINT,\r\nc SMALLINT,\r\nd SMALLINT,\r\ne SMALLINT,\r\nf SMALLINT,\r\ng SMALLINT \r\n)\r\nINSERT [tb]\r\nSELECT 1,2,3,4,5,2,3 UNION ALL\r\nSELECT 4,5,6,7,7,2,0 UNION ALL\r\nSELECT 4,9,6,7,7,9,6\r\nGO\r\n--SELECT * FROM [tb]\r\n \r\n-->SQL\u67e5\u8be2\u5982\u4e0b:\r\n \r\nSELECT *,\r\n    (SELECT MAX(a)\r\n     FROM(\r\n       SELECT a UNION ALL       --\u7528select \u53d6\u51fa\u503cunion\u6210table\r\n       SELECT b UNION ALL\r\n       SELECT c UNION ALL\r\n       SELECT d UNION ALL\r\n       SELECT e UNION ALL\r\n       SELECT f UNION ALL\r\n       SELECT g\r\n       ) AS t   \r\n    ) AS maxvalue\r\nFROM tb\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3b\u8981\u662f\u4e00\u884c\u7684\u6570\u636e\u67d0\u4e9b\u5b57\u6bb5\u6574\u6210\u4e00\u4e2atable,\u5bf9\u6b64table\u8fdb\u884c\u64cd\u4f5c\u5373\u53ef \u57fa\u7840\uff1aselect *, (selec [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-625","post","type-post","status-publish","format-standard","hentry","category-sql-server"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/625","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/comments?post=625"}],"version-history":[{"count":0,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/625\/revisions"}],"wp:attachment":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/media?parent=625"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/categories?post=625"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/tags?post=625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}