{"id":833,"date":"2010-08-08T22:48:00","date_gmt":"2010-08-08T13:48:00","guid":{"rendered":"http:\/\/www.code-life.jp\/blog\/?p=833"},"modified":"2010-08-10T12:26:01","modified_gmt":"2010-08-10T03:26:01","slug":"%e6%95%b0%e5%80%a4%e3%82%92%e8%bf%94%e3%81%99%e3%81%a0%e3%81%91%e3%81%ae%e3%83%93%e3%83%a5%e3%83%bc%e3%81%a3%e3%81%a6%e4%be%bf%e5%88%a9%e3%81%a0%e3%82%88%e3%81%ad","status":"publish","type":"post","link":"https:\/\/www.code-life.jp\/blog\/2010\/08\/08\/%e6%95%b0%e5%80%a4%e3%82%92%e8%bf%94%e3%81%99%e3%81%a0%e3%81%91%e3%81%ae%e3%83%93%e3%83%a5%e3%83%bc%e3%81%a3%e3%81%a6%e4%be%bf%e5%88%a9%e3%81%a0%e3%82%88%e3%81%ad\/","title":{"rendered":"\u6570\u5024\u3092\u8fd4\u3059\u3060\u3051\u306e\u30d3\u30e5\u30fc\u3063\u3066\u4fbf\u5229\u3060\u3088\u306d"},"content":{"rendered":"<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u6570\u5b57\u3092\u8fd4\u3059\u3060\u3051\u30d3\u30e5\u30fc\u3092\u4f5c\u6210\u3057\u3066\u304a\u304f\u3068\u3001\u4f55\u304b\u3068\u4fbf\u5229\u306a\u3053\u3068\u304c\u591a\u3044\u3002<\/p>\n<pre class=\"program\"><code> \/*0\uff5e9\u307e\u3067\u306e\u6570\u5024\u3092\u8fd4\u3059\u3060\u3051\u306eVIEW*\/\r\n create view vnum as\r\n   select 0 as n union all\r\n   select 1 as n union all\r\n   select 2 as n union all\r\n   select 3 as n union all\r\n   select 4 as n union all\r\n   select 5 as n union all\r\n   select 6 as n union all\r\n   select 7 as n union all\r\n   select 8 as n union all\r\n   select 9 as n\r\n ;<\/code><\/pre>\n<p>\u3069\u306e\u3088\u3046\u306a\u5834\u9762\u306b\u4f7f\u3046\u306e\u304b\u3068\u3044\u3046\u3068\u3001\u4ee5\u524d\u7d39\u4ecb\u3057\u305f<a href=\"https:\/\/www.code-life.jp\/blog\/2010\/01\/09\/%ef%bc%91%e5%b9%b4%e5%88%86%e3%81%ae%e5%b9%b4%e6%9c%88%e6%97%a5%e3%82%92%e7%94%9f%e6%88%90%e3%81%99%e3%82%8b\/\">\uff11\u5e74\u5206\u306e\u5e74\u6708\u65e5\u3092\u751f\u6210\u3059\u308b<\/a>\u6642\u3084\u3001<a href=\"https:\/\/www.code-life.jp\/blog\/2009\/12\/26\/%e6%ad%af%e6%8a%9c%e3%81%91%e3%81%aeid%e3%82%92%e5%85%a8%e3%81%a6%e6%b1%82%e3%82%81%e3%82%8b\/\">\u6b6f\u629c\u3051\u306eID\u3092\u5168\u3066\u6c42\u3081\u308b<\/a>\u6642\u306a\u3069\u3067\u3042\u308b\u3002<\/p>\n<p>\u3053\u308c\u3089\u306eSQL\u6587\u306b\u4e0a\u8a18\u306e\u30d3\u30e5\u30fc\u3092\u9069\u7528\u3059\u308c\u3070\u3001\u767a\u884c\u3059\u308bSQL\u6587\u3092\u77ed\u304f\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n<p>\u5b9f\u969b\u306b<a href=\"..\/..\/blog\/2010\/01\/09\/%ef%bc%91%e5%b9%b4%e5%88%86%e3%81%ae%e5%b9%b4%e6%9c%88%e6%97%a5%e3%82%92%e7%94%9f%e6%88%90%e3%81%99%e3%82%8b\/\">\uff11\u5e74\u5206\u306e\u5e74\u6708\u65e5\u3092\u751f\u6210\u3059\u308b<\/a>\u306eSQL\u6587\u3092\u66f8\u304d\u63db\u3048\u3066\u307f\u3088\u3046\u3002<\/p>\n<p>\u6bd4\u8f03\u3057\u3084\u3059\u3044\u3088\u3046\u306b\u3001SQL\u6587\u3092\u518d\u63b2\u3002<\/p>\n<pre class=\"program\"><code> \/*\uff11\u5e74\u5206\u306e\u5e74\u6708\u65e5\u751f\u6210*\/\r\n select date_format(date_add('20100101', interval(number) day), '%Y%m%d') as yyyymmdd\r\n from (\r\n   select hundred.n + tens.n + ones.n as number\r\n   from (\r\n     select 0 as n union all\r\n     select 1 as n union all\r\n     select 2 as n union all\r\n     select 3 as n union all\r\n     select 4 as n union all\r\n     select 5 as n union all\r\n     select 6 as n union all\r\n     select 7 as n union all\r\n     select 8 as n union all\r\n     select 9 as n\r\n   ) as ones cross join (\r\n     select 0 as n union all\r\n     select 10 as n union all\r\n     select 20 as n union all\r\n     select 30 as n union all\r\n     select 40 as n union all\r\n     select 50 as n union all\r\n     select 60 as n union all\r\n     select 70 as n union all\r\n     select 80 as n union all\r\n     select 90 as n\r\n   ) as tens cross join (\r\n     select 0 as n union all\r\n     select 100 as n union all\r\n     select 200 as n union all\r\n     select 300 as n\r\n   ) as hundred\r\n ) as dummy\r\n where date_format(date_add('20100101', interval(number) day), '%Y%m%d') &lt; '20110101'\r\n order by yyyymmdd asc;\r\n<\/code><\/pre>\n<p>\u3053\u306eSQL\u6587\u306b\u4eca\u56de\u7d39\u4ecb\u3057\u305f\u30d3\u30e5\u30fc\u3092\u9069\u7528\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308b\u3002<\/p>\n<pre class=\"program\"><code> \/*\uff11\u5e74\u5206\u306e\u5e74\u6708\u65e5\u751f\u6210*\/\r\n<\/code> select date_format(date_add('20100101', interval(number) day), '%Y%m%d') as yyyymmdd\r\n from (\r\n<span style=\"text-decoration: line-through;\">   --select hundred.n * 100 + tens.n * 10 + ones.n as number\r\n   --from vnum as ones\r\n   --cross join vnum as tens\r\n   --cross join (select n from vnum where n between 0 and 3) as hundred\r\n<\/span>   select hundred.n + tens.n + ones.n as number\r\n   from vnum as ones\r\n   cross join (select n * 10 as n from vnum) as tens\r\n   cross join (select n * 100 as n from vnum where n between 0 and 3) as hundred\r\n ) as dummy\r\n where date_format(date_add('20100101', interval(number) day), '%Y%m%d') &lt; '20110101'\r\n order by yyyymmdd asc;\r\n<\/pre>\n<p>\u4ee5\u4e0a\u3001\u6570\u5024\u3092\u8fd4\u3059\u3060\u3051\u306e\u30d3\u30e5\u30fc\u3063\u3066\u3001\u4f5c\u3063\u3066\u304a\u304f\u3068\u4f7f\u3044\u56de\u3057\u304c\u3067\u304d\u3066\u4fbf\u5229\u3060\u3088\u306d\u3001\u3068\u3044\u3046\u304a\u8a71\u3067\u3057\u305f\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u3063\u3066\u3082\u826f\u3044\u306e\u3067\u3042\u308c\u3070\u3001\u5185\u90e8\u3067union\u6587\u3092\u3044\u304f\u3064\u3082\u4f7f\u3063\u3066\u3044\u308b\u30d3\u30e5\u30fc\u3088\u308a\u3082\u30c6\u30fc\u30d6\u30eb\u306e\u307b\u3046\u304c\u6709\u5229\u306a\u306e\u306f\u3001explain\u306e\u7d50\u679c\u3092\u898b\u308c\u3070\u660e\u3089\u304b\u3067\u3059\u306a\u3002\u3068\u3044\u3046\u304b\u3001\u898b\u306a\u304f\u3066\u3082(ry\u3002<\/p>\n<p>2010\/08\/09\u8ffd\u8a18: SQL\u6587\u3092\u4e00\u90e8\u4fee\u6b63\u3002<\/p>\n<p>\u300cselect hundred.n * 100 + tens.n * 10 + ones.n as number\uff5e\u300d(\u4fee\u6b63\u524d)\u3068\u300cselect hundred.n + tens.n + ones.n as number\uff5e\u300d(\u4fee\u6b63\u5f8c)\u3068\u3067\u306f\u300110000\u56de\u5b9f\u884c\u3057\u305f\u5834\u5408\u3001\u30d3\u30e5\u30fc\u306e\u5834\u5408\u3067\u306f0.18sec\u306e\u5dee\u304c\u3001\u30c6\u30fc\u30d6\u30eb\u306e\u5834\u5408\u3067\u306f0.08sec\u306e\u5dee\u304c\u51fa\u305f\u306e\u3067(\u79c1\u306e\u74b0\u5883\u3067\u306e\u8a71\u3002benchmark\u3092\u4f7f\u7528\u3057\u3066\u8a08\u6e2c)\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u6570\u5b57\u3092\u8fd4\u3059\u3060\u3051\u30d3\u30e5\u30fc\u3092\u4f5c\u6210\u3057\u3066\u304a\u304f\u3068\u3001\u4f55\u304b\u3068\u4fbf\u5229\u306a\u3053\u3068\u304c\u591a\u3044\u3002 \/*0\uff5e9\u307e\u3067\u306e\u6570\u5024\u3092\u8fd4\u3059\u3060\u3051\u306eVIEW*\/ create view vnum as select 0 as n union all selec&hellip; <a class=\"more-link\" href=\"https:\/\/www.code-life.jp\/blog\/2010\/08\/08\/%e6%95%b0%e5%80%a4%e3%82%92%e8%bf%94%e3%81%99%e3%81%a0%e3%81%91%e3%81%ae%e3%83%93%e3%83%a5%e3%83%bc%e3%81%a3%e3%81%a6%e4%be%bf%e5%88%a9%e3%81%a0%e3%82%88%e3%81%ad\/\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">\u6570\u5024\u3092\u8fd4\u3059\u3060\u3051\u306e\u30d3\u30e5\u30fc\u3063\u3066\u4fbf\u5229\u3060\u3088\u306d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[11,9],"tags":[],"_links":{"self":[{"href":"https:\/\/www.code-life.jp\/blog\/wp-json\/wp\/v2\/posts\/833"}],"collection":[{"href":"https:\/\/www.code-life.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.code-life.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.code-life.jp\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.code-life.jp\/blog\/wp-json\/wp\/v2\/comments?post=833"}],"version-history":[{"count":8,"href":"https:\/\/www.code-life.jp\/blog\/wp-json\/wp\/v2\/posts\/833\/revisions"}],"predecessor-version":[{"id":836,"href":"https:\/\/www.code-life.jp\/blog\/wp-json\/wp\/v2\/posts\/833\/revisions\/836"}],"wp:attachment":[{"href":"https:\/\/www.code-life.jp\/blog\/wp-json\/wp\/v2\/media?parent=833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.code-life.jp\/blog\/wp-json\/wp\/v2\/categories?post=833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.code-life.jp\/blog\/wp-json\/wp\/v2\/tags?post=833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}