\nvolumn<\/td>\n | \u671f\u6570<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \u8be5\u8868\u5b58\u50a8\u4e86\u67d0\u6742\u5fd7\u7684\u5e74\u4efd\uff0c\u6708\u4efd\u548c\u671f\u6570\u3002\u5982\u679c\u9700\u6c42\u5bf9\u8be5\u8868\u5185\u5bb9\u4f5c\u5982\u4e0b\u663e\u793a\uff1a<\/p>\n \n\n\n2010\u5e7412\u6708<\/td>\n | \u7b2c1\u671f\u7b2c2\u671f\u7b2c3\u671f \u7b2c4\u671f<\/td>\n<\/tr>\n | \n2010\u5e7411\u6708<\/td>\n | \u7b2c1\u671f\u7b2c2\u671f\u7b2c3\u671f \u7b2c4\u671f\u7b2c5\u671f<\/td>\n<\/tr>\n | \n2010\u5e7410\u6708<\/td>\n | \u7b2c1\u671f\u7b2c2\u671f\u7b2c3\u671f \u7b2c4\u671f<\/td>\n<\/tr>\n | \n2010\u5e749\u6708<\/td>\n | \u7b2c1\u671f\u7b2c2\u671f\u7b2c3\u671f \u7b2c4\u671f\u7b2c5\u671f<\/td>\n<\/tr>\n | \n2010\u5e748\u6708<\/td>\n | \u7b2c1\u671f\u7b2c2\u671f\u7b2c3\u671f \u7b2c4\u671f <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n sql\u8be5\u600e\u4e48\u5199\u5462\uff1f\u6309\u7167\u5e74\u4efd\u548c\u6708\u4efd\u505agroup by\uff1f\u7136\u540e\u6309\u7167\u5e74\u4efd\u548c\u6708\u4efd\u505a\u5012\u53d9\u6392\u5217\uff1f<\/p>\n \n \n- select<\/span> <\/span>year<\/span>,<\/span>month<\/span> <\/span>from<\/span> magazine <\/span>group<\/span> <\/span>by<\/span> <\/span>year<\/span>,<\/span>month<\/span> <\/span>order<\/span> <\/span>by<\/span> <\/span>year<\/span> <\/span>desc<\/span>,<\/span>month<\/span> <\/span>desc<\/span> <\/span><\/span><\/li>\n<\/ol>\n<\/div>\n
<\/font> \u90a3\u5177\u4f53\u7684\u671f\u6570\u4fe1\u606f\u5c31\u4e22\u4e86\uff1f\u80fd\u4e0d\u80fd\u505agroup by\u7684\u65f6\u5019\uff0c\u8fd8\u80fd\u8fd4\u56de\u5728\u67d0\u4e2a\u5e74\u4efdyear\u548c\u6708\u4efdmonth\u5206\u7ec4\u4e0b\u7684\u6240\u6709\u671f\u6570volumn\u4fe1\u606f\uff1f\uff08\u67d0\u4e2a\u5e74\u4efd+\u6708\u4efd\u4e0b\u7684\u671f\u6570\u4fe1\u606f\u662f\u4e0d\u56fa\u5b9a\u7684\uff0c\u53ea\u80fd\u901a\u8fc7\u6570\u636e\u5e93\u67e5\u8be2\u624d\u80fd\u83b7\u5f97\uff09<\/p>\n\u8be5\u662fGROUP_CONCAT\u4e0a\u9635\u7684\u65f6\u5019\u4e86\u3002<\/p>\n \n \n- select<\/span> <\/span>year<\/span>,<\/span>month<\/span> GROUP_CONCAT(volumn) <\/span>from<\/span> magazine <\/span>group<\/span> <\/span>by<\/span> <\/span>year<\/span>,<\/span>month<\/span> <\/span>order<\/span> <\/span>by<\/span> <\/span>year<\/span> <\/span>desc<\/span>, <\/span>month<\/span> <\/span>desc<\/span> <\/span><\/span><\/li>\n<\/ol>\n<\/div>\n
\u8fd9\u6837\uff0c\u67e5\u8be2\u7684\u8fd4\u56de\u7ed3\u679c\u7c7b\u4f3c\u4e8e\uff1a<\/p>\n \n\n\nyear<\/td>\n | month<\/td>\n | GROUP_CONCAT(volumn)<\/td>\n<\/tr>\n | \n2010<\/td>\n | 12<\/td>\n | 1,2,3,4<\/td>\n<\/tr>\n | \n2010<\/td>\n | 11<\/td>\n | 1,2,3,4,5<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \u4e0d\u9519\u5427\uff1f<\/p>\n \u8fd8\u6709\u70b9\u95ee\u9898\u9700\u8981\u8865\u5145\u4e0b\uff0c\u5c31\u662f\u4f5c\u4e3aGROUP_CONCAT\u51fd\u6570\u53c2\u6570\u7684\u5b57\u6bb5\uff0c\u5982\u8fc7\u8fd4\u56de\u503c\u4e3astring\uff0c\u5219\u4e0a\u9762\u7684sql\u8bed\u53e5\u5df2\u7ecf\u6ca1\u6709\u95ee\u9898\uff0c\u4f46\u662f\u5982\u679c\u662f number\uff0c\u5219\u8fd4\u56de\u7684GROUP_CONCAT(volumn)\u503c\u4e3aBLOB\u7c7b\u578b\uff08\u5176\u5b9e\u4e0a\u9762\u4f8b\u5b50\u8fd4\u56de\u7684\u5c31\u662f\u4e00\u4e2ablob\u7c7b\u578b\uff0c\u6211\u53ea\u662f\u4e3a\u4e86\u6f14\u793a\u7684\u65b9\u4fbf\uff09\uff0c\u9700\u8981\u505a\u4e00\u4e0b\u8f6c\u5316\u3002<\/p>\n \n \n- select<\/span> <\/span>year<\/span>,<\/span>month<\/span> GROUP_CONCAT(conv( oct( volumn ) , 8, 10 )) <\/span>from<\/span> magazine <\/span>group<\/span> <\/span>by<\/span> <\/span>year<\/span>,<\/span>month<\/span> <\/span>order<\/span> <\/span>by<\/span> <\/span>year<\/span> <\/span>desc<\/span>, <\/span>month<\/span> <\/span>desc<\/span> <\/span><\/span><\/li>\n<\/ol>\n<\/div>\n
<\/font> \u4e0a\u9762\u7684sql\u5bf9volumn\u505a\u4e86\u4e00\u4e2a\u4ece8\u8fdb\u5236\u523010\u8fdb\u5236\u7684\u8f6c\u6362\uff0c\u8fd9\u6837\u8fd4\u56de\u7684\u5c31\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\u4e86\u3002<\/p>\nmysql\u9ed8\u8ba4\u4f1a\u4ee5‘,’\u6765\u5206\u9694\u591a\u7684\u503c\uff0c\u5982\u679c\u60f3\u7528\u5176\u4ed6\u7684\u5206\u9694\u7b26\u6765\u5206\u9694\u8fd4\u56de\u7ed3\u679c\uff0c\u6bd4\u5982\u671f\u671b\u8fd4\u56de\u503c\u662f\u8fd9\u6837\u7684\uff1a1|2|3|4<\/p>\n \u8fd9\u53ef\u4ee5\u7528SEPARATOR\u6765\u641e\u5b9a\u3002<\/font><\/code><\/p>\n\n \n- select<\/span> <\/span>year<\/span>,<\/span>month<\/span> GROUP_CONCAT(conv( oct( volumn ) , 8, 10 ) SEPARATOR <\/span>‘|’<\/span>) <\/span>from<\/span> magazine <\/span>group<\/span> <\/span>by<\/span> <\/span>year<\/span>,<\/span>month<\/span> <\/span>order<\/span> <\/span>by<\/span> <\/span>year<\/span> <\/span>desc<\/span>, <\/span>month<\/span> <\/span>desc<\/span> <\/span><\/span><\/li>\n<\/ol>\n<\/div>\n
\u66f4\u725b\u7684\u662f\uff0c\u4f60\u751a\u81f3\u53ef\u4ee5\u5bf9\u8fd4\u56de\u7684volumn\u8fdb\u884c\u6392\u5e8f\uff01\uff01<\/p>\n \n \n- select<\/span> <\/span>year<\/span>,<\/span>month<\/span> GROUP_CONCAT(conv( oct( volumn ) , 8, 10 ) <\/span>order<\/span> <\/span>by<\/span> volumn <\/span>desc<\/span> SEPARATOR <\/span>‘|’<\/span>) <\/span>from<\/span> magazine <\/span>group<\/span> <\/span>by<\/span> <\/span>year<\/span>,<\/span>month<\/span> <\/span>order<\/span> <\/span>by<\/span> <\/span>year<\/span> <\/span>desc<\/span>, <\/span>month<\/span> <\/span>desc<\/span> <\/span><\/span><\/li>\n<\/ol>\n<\/div>\n
\u8fd9\u4e2a\u4e0d\u5e38\u7528\u7684\u4e1c\u4e1c\uff0c\u8fd8\u662f\u6bd4\u8f83\u597d\u7528\u7684\u3002<\/p>\n \u5f15\u7528\uff1ahttp:\/\/javeye.javaeye.com\/blog\/558093<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\u6211\u4eec\u77e5\u9053\uff0cgroup by\u53ef\u4ee5\u5c06sql\u67e5\u8be2\u7ed3\u679c\u6309\u7167group by\u540e\u9762\u5217\u8fdb\u884c\u5206\u7c7b\u663e\u793a\u3002\u6bd4\u5982\uff1a<\/p>\n \n \n- select<\/span> columnA,columnB <\/span>from<\/span> <\/span>table<\/span> <\/span>group<\/span> <\/span>by<\/span> columnA,columnB <\/span><\/span><\/li>\n<\/ol>\n<\/div>\n
\u5219<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1110"}],"collection":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/comments?post=1110"}],"version-history":[{"count":0,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1110\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/media?parent=1110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/categories?post=1110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/tags?post=1110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}} | | |