{"id":4747,"date":"2018-06-21T11:16:51","date_gmt":"2018-06-21T02:16:51","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=4747"},"modified":"2023-04-26T08:34:34","modified_gmt":"2023-04-25T23:34:34","slug":"%e3%80%90sql%e3%80%91%e3%80%8c%e3%82%b5%e3%83%96%e3%82%af%e3%82%a8%e3%83%aa%e3%80%8d%e3%81%ae%e7%a8%ae%e9%a1%9e","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=4747","title":{"rendered":"\u3010SQL\u3011\u300c\u30b5\u30d6\u30af\u30a8\u30ea(\u526f\u554f\u3044\u5408\u308f\u305b)\u300d\u306b\u3064\u3044\u3066"},"content":{"rendered":"<h2>\u30b5\u30d6\u30af\u30a8\u30ea\uff08\u526f\u554f\u3044\u5408\u308f\u305b\uff09\u3068\u306f\uff1f<\/h2>\n<p>\u4e00\u8a00\u3067\u8a00\u3048\u3070\u3001SELECT\u6587\u306e\u4e2d\u3067\u4f7f\u7528\u3067\u304d\u308b<span style=\"color: #ff0000;\"><strong>\u300c\u4f7f\u3044\u6368\u3066\u306e\u30d3\u30e5\u30fc\u300d<\/strong><\/span>\u3067\u3059\u3002<\/p>\n<h2>\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u968e\u5c64\u3092\u5897\u3084\u3057\u305f\u5834\u5408<\/h2>\n<p>\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u968e\u5c64\u3092\u5897\u3084\u3059\u3068\u3001\u8907\u6570\u6587\u3067\u306f\u306a\u304f\u3001\u5358\u4e00\u306eSQL\u3067\u66f8\u3051\u308b\u3068\u3044\u3046\u30e1\u30ea\u30c3\u30c8\u3082\u3042\u308a\u307e\u3059\u304c\u3001\u4e0b\u8a18\u306e\u30c7\u30e1\u30ea\u30c3\u30c8\u304c\u3042\u308b\u306e\u3067\u306a\u308b\u3079\u304f\u907f\u3051\u305f\u65b9\u304c\u3088\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<ul>\n<li>SQL\u6587\u304c\u8aad\u307f\u3065\u3089\u304f\u306a\u308b\u3002<\/li>\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u60aa\u304f\u306a\u308b\u3002<\/li>\n<\/ul>\n<h2>\u30b5\u30d6\u30af\u30a8\u30ea\u306b\u540d\u524d\u3092\u4ed8\u3051\u308b\u306b\u306f\uff1f<\/h2>\n<p>AS\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3082\u3088\u3044\u3067\u3059\u3057\u3001\u7701\u7565\u3057\u3066\u3082\u304b\u307e\u3044\u307e\u305b\u3093\u3002<\/p>\n<h2>\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u30e1\u30ea\u30c3\u30c8<\/h2>\n<p>\u30b5\u30d6\u30af\u30a8\u30ea \u306f\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u9762\u306b\u304a\u3044\u3066\u4e0d\u5229\u306a\u70b9\u304c\u591a\u3044\u3067\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001\u7d50\u5408\u304c\u95a2\u4fc2\u3059\u308b\u30af\u30a8\u30ea\u306b\u304a\u3044\u3066\u306f\u6027\u80fd\u9762\u3067\u30b5\u30d6\u30af\u30a8\u30ea\u3092\u4f7f\u3063\u3066\u3044\u304f\u3068\u3044\u3046\u306e\u3082\u9078\u629e\u80a2\u306e\u4e00\u3064\u306b\u306a\u3063\u3066\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u4e8c\u3064\u306e\u4f8b\u304c\u3042\u308b\u3068\u3057\u307e\u3059\u3002<\/p>\n<h3>join\u3092\u5148\u306b\u3084\u3063\u3066\u3001\u6761\u4ef6\u3092\u7d5e\u308b\u3002<\/h3>\n<pre class=\"lang:default decode:true\">select * from \u30c6\u30fc\u30d6\u30eb1\r\ninner join \u30c6\u30fc\u30d6\u30eb2 on \u7d50\u5408\u6761\u4ef6\r\nwhere \u6761\u4ef6<\/pre>\n<h3>\u30b5\u30d6\u30af\u30a8\u30ea \u306e\u4e2d\u3067\u6761\u4ef6\u3092\u62bd\u51fa\u3057\u3066\u305d\u308c\u3092join\u3059\u308b\u3002<\/h3>\n<pre class=\"lang:default decode:true\">select * from \u30c6\u30fc\u30d6\u30eb1\r\ninner join (\u6761\u4ef6\u3064\u304d\u306e\u30b5\u30d6\u30af\u30a8\u30ea) on \u7d50\u5408\u6761\u4ef6<\/pre>\n<p>\u3053\u306e\u5834\u5408\u3060\u3068\u3001join\u3067\u7d50\u5408\u3059\u308b\u30c6\u30fc\u30d6\u30eb\u306e\u4ef6\u6570\u304c\u6e1b\u308b\u306e\u3067\u3001\u30b5\u30d6\u30af\u30a8\u30ea \u3092\u4f7f\u7528\u3057\u305f\u65b9\u304c\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u826f\u304f\u306a\u308b\u30b1\u30fc\u30b9\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h2>\u30b5\u30d6\u30af\u30a8\u30ea \u306e\u554f\u984c\u70b9<\/h2>\n<h3>\u30b5\u30d6\u30af\u30a8\u30ea \u306e\u8a08\u7b97\u30b3\u30b9\u30c8\u304c\u4e0a\u4e57\u305b\u3055\u308c\u308b\u3002<\/h3>\n<p>\u30b5\u30d6\u30af\u30a8\u30ea \u306f\u30c6\u30fc\u30d6\u30eb\u3068\u9055\u3063\u3066\u5b9f\u4f53\u306e\u30c7\u30fc\u30bf\u3092\u4fdd\u6301\u3057\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3073\u306bSELECT\u6587\u304c\u767a\u884c\u3055\u308c\u3066\u8a08\u7b97\u30b3\u30b9\u30c8\u304c\u304b\u304b\u308a\u307e\u3059\u3002\u30b5\u30d6\u30af\u30a8\u30ea \u306e\u4e2d\u8eab\u304c\u8907\u96d1\u3067\u3042\u308c\u3070\u3042\u308b\u307b\u3069\u3053\u306e\u30b3\u30b9\u30c8\u306f\u5897\u3048\u307e\u3059\u3002<\/p>\n<h3>\u30c7\u30fc\u30bf\u306eI\/O\u30b3\u30b9\u30c8\u304c\u304b\u304b\u308b\u3002<\/h3>\n<p>\u8a08\u7b97\u3057\u305f\u7d50\u679c\u304c\u30e1\u30e2\u30ea\u4e0a\u306b\u4e57\u308c\u3070\u65e9\u3044\u306e\u3067\u3059\u304c\u3001\u30e1\u30e2\u30ea\u304b\u3089\u306f\u307f\u51fa\u305f\u5834\u5408\u306f\u300cTEMP\u843d\u3061\u300d\u306b\u306a\u3063\u3066\u901f\u5ea6\u304c\u4f4e\u4e0b\u3057\u307e\u3059\u3002<\/p>\n<h3>\u6700\u9069\u5316\u304c\u53d7\u3051\u3089\u308c\u306a\u3044\u3002<\/h3>\n<p>\u660e\u793a\u7684\u306b\u5236\u7d04\u3084\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f7f\u3063\u3066\u3044\u308b\u30c6\u30fc\u30d6\u30eb\u3068\u9055\u3063\u3066\u3001\u30b5\u30d6\u30af\u30a8\u30ea \u306b\u306f\u305d\u306e\u3088\u3046\u306a\u30e1\u30bf\u60c5\u5831\u304c\u4e00\u5207\u5b58\u5728\u3057\u306a\u3044\u3002<\/p>\n<p>\u30aa\u30d7\u30c6\u30a3\u30de\u30a4\u30b6\u304c\u30af\u30a8\u30ea\u3092\u89e3\u6790\u3059\u308b\u305f\u3081\u306e\u5fc5\u8981\u306a\u60c5\u5831\u304c\u30b5\u30d6\u30af\u30a8\u30ea \u306e\u7d50\u679c\u304b\u3089\u306f\u5f97\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<h3>\u5bfe\u7b56<\/h3>\n<h4>\u672c\u5f53\u306b\u30b5\u30d6\u30af\u30a8\u30ea \u3092\u4f7f\u308f\u306a\u3044\u3068\u3067\u304d\u306a\u3044\u304b\u3092\u5e38\u306b\u8003\u3048\u308b\u3088\u3046\u306b\u3059\u308b\u3053\u3068\u3002<\/h4>\n<p>\u30a6\u30a4\u30f3\u30c9\u30a6\u95a2\u6570\u306a\u3069\u3067\u7f6e\u304d\u63db\u3048\u3089\u308c\u306a\u3044\u304b\u8003\u3048\u308b\u3002<\/p>\n<h2>\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u6ce8\u610f\u70b9<\/h2>\n<p>\u57fa\u672c\u7684\u306b\u306f\u3001\u901a\u5e38\u306e\u30b5\u30d6\u30af\u30a8\u30ea\u3067\u3042\u308c\u3070\u3001\u8907\u6570\u884c\u8fd4\u3059\u306e\u3067<span style=\"color: #ff0000;\"><strong>SELECT\u53e5\u306b\u306f\u66f8\u3051\u307e\u305b\u3093\u3002<\/strong><\/span><\/p>\n<p>\u307e\u305f\u3001WHERE\u53e5\u306b\u66f8\u3044\u305f\u3068\u3057\u3066\u3082\u3001<span style=\"color: #ff0000;\"><strong>\u6bd4\u8f03\u6f14\u7b97\u5b50\u3092\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002<\/strong><\/span><\/p>\n<p>\u3057\u304b\u3057\u3001<span style=\"color: #ff0000;\"><strong>\u300c\u30b9\u30ab\u30e9\u30fb\u30b5\u30d6\u30af\u30a8\u30ea\u300d<\/strong><\/span>\u3068\u3044\u3046\u985e\u306e\u30b5\u30d6\u30af\u30a8\u30ea\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u66f8\u3051\u308b\u5834\u6240\u304c\u5e83\u304c\u308a\u307e\u3059\u3002<\/p>\n<h2>\u30b9\u30ab\u30e9\u30fb\u30b5\u30d6\u30af\u30a8\u30ea\u3068\u306f\uff1f<\/h2>\n<p>\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u5b9f\u884c\u7d50\u679c\u3068\u3057\u3066\u3001\u300c\u5fc5\u305a1\u884c\u30011\u5217\u306e\u5024\u3092\u8fd4\u3059\u300d\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u3053\u3068\u3067\u3059\u3002<\/p>\n<h3>\u30b9\u30ab\u30e9\u30fb\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u623b\u308a\u5024\u306e\u4f8b<\/h3>\n<table width=\"50\">\n<tbody>\n<tr>\n<th>ITEM<\/th>\n<\/tr>\n<tr>\n<td>\u5546\u54c1\uff11<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u30b9\u30ab\u30e9\u30fb\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u7279\u5fb4<\/h3>\n<h4>\u6bd4\u8f03\u6f14\u7b97\u5b50(=\u3001&lt;\u3001&gt;\u7b49)\u3092\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/h4>\n<p>\u4f8b\u3048\u3070\u3001<span style=\"color: #ff0000;\"><strong>WHERE\u53e5\u3067\u306f\u3001\u96c6\u8a08\u95a2\u6570\u3092\u4f7f\u3046\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u304c\u3001\u30b5\u30d6\u30af\u30a8\u30ea\u3067\u96c6\u8a08\u3059\u308bSELECT\u6587\u3092\u4f5c\u3063\u3066\u3001\u305d\u306e\u7d50\u679c\u3092\u8fd4\u305b\u3070\u3001WHERE\u53e5\u3067\u96c6\u8a08\u7d50\u679c\u306e\u62bd\u51fa\u3068\u8a00\u3046\u3088\u3046\u306a\u4f7f\u3044\u65b9\u3082\u53ef\u80fd<\/strong><\/span>\u3067\u3059\u3002<\/p>\n<h4>SELECT\u6587\u306e\u4e2d\u3067\u3001\u66f8\u3051\u308b\u5834\u6240\u304c\u591a\u3044\u3002<\/h4>\n<p>\u57fa\u672c\u7684\u306b\u306f\u3001\u8907\u6570\u884c\u3092\u8fd4\u3059\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u5834\u5408\u306f\u3001\u66f8\u3051\u308b\u5834\u6240\u3082\u5236\u9650\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u30b9\u30ab\u30e9\u30fb\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u5834\u5408\u306f\u3001\u5b9a\u6570\u3084\u5217\u540d\u3092\u8a18\u8ff0\u3067\u304d\u308b\u5834\u6240\u3067\u3042\u308c\u3070\u3069\u3053\u3067\u3082\u3088\u304f\u3001\u8a18\u8ff0\u3067\u304d\u308b\u53e5\u304c\u591a\u3044\u3067\u3059\u3002<\/p>\n<ul>\n<li>SELECT\u53e5<\/li>\n<li>GROUP BY\u53e5<\/li>\n<li>HAVING\u53e5<\/li>\n<li>ORDER BY\u53e5<\/li>\n<\/ul>\n<h2>\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea<\/h2>\n<p><span style=\"color: #ff0000;\"><strong>\u8907\u6570\u884c\u5024\u3092\u8fd4\u3059\u3088\u3046\u306a\u30b5\u30d6\u30af\u30a8\u30ea\u3067\u3082\u3001\u6761\u4ef6\u3092\u6307\u5b9a\u3057\u3066\u30c6\u30fc\u30d6\u30eb\u306e\u4e00\u90e8\u5206\u306e\u307f\u306b\u7d5e\u308b\u3053\u3068\u3067\u3001\u8ff0\u8a9e<\/strong><strong>(=\u3001&lt;\u3001&gt;\u7b49)<\/strong><strong>\u3092\u4f7f\u3048\u308b\u3088\u3046\u306b\u3059\u308b\u76ee\u7684\u3067\u4f7f\u3046\u30b5\u30d6\u30af\u30a8\u30ea<\/strong><\/span>\u3067\u3059\u3002<\/p>\n<p>\u8a73\u3057\u304f\u306f\u4e0b\u8a18\u306e\u8a18\u4e8b\u3067\u3082\u89e3\u8aac\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"Lpw1e99OJo\"><p><a href=\"http:\/\/www.code-magagine.com\/?p=4736\">\u3010SQL\u3011\u300c\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea\u300d\u3068\u306f\u4f55\u304b\uff1f<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"http:\/\/www.code-magagine.com\/?p=4736&#038;embed=true#?secret=Lpw1e99OJo\" data-secret=\"Lpw1e99OJo\" width=\"500\" height=\"282\" title=\"&#8220;\u3010SQL\u3011\u300c\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea\u300d\u3068\u306f\u4f55\u304b\uff1f&#8221; &#8212; \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30de\u30ac\u30b8\u30f3\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"\u30b5\u30d6\u30af\u30a8\u30ea\uff08\u526f\u554f\u3044\u5408\u308f\u305b\uff09\u3068\u306f\uff1f \u4e00\u8a00\u3067\u8a00\u3048\u3070\u3001SELECT\u6587\u306e\u4e2d\u3067\u4f7f\u7528\u3067\u304d\u308b\u300c\u4f7f\u3044\u6368\u3066\u306e\u30d3\u30e5\u30fc\u300d\u3067\u3059\u3002 \u30b5\u30d6\u30af\u30a8\u30ea\u306e\u968e\u5c64\u3092\u5897\u3084\u3057\u305f\u5834\u5408 \u30b5\u30d6\u30af\u30a8\u30ea\u306e\u968e\u5c64\u3092\u5897\u3084\u3059\u3068\u3001\u8907\u6570\u6587\u3067\u306f\u306a\u304f\u3001\u5358\u4e00\u306eSQL\u3067\u66f8\u3051\u308b\u3068\u3044\u3046\u30e1\u30ea\u30c3\u30c8\u3082\u3042 [&hellip;]","protected":false},"author":1,"featured_media":4823,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[24],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/4747"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4747"}],"version-history":[{"count":19,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/4747\/revisions"}],"predecessor-version":[{"id":19206,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/4747\/revisions\/19206"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/media\/4823"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4747"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4747"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}