{"id":5922,"date":"2025-09-23T16:16:05","date_gmt":"2025-09-23T07:16:05","guid":{"rendered":"https:\/\/sky-peace.net\/?p=5922"},"modified":"2025-09-23T16:16:05","modified_gmt":"2025-09-23T07:16:05","slug":"db-sp-2","status":"publish","type":"post","link":"https:\/\/sky-peace.net\/certified\/db-sp-2\/","title":{"rendered":"SQL\u306e\u58c1\u3092\u8d8a\u3048\u308b\uff01DBA\u5348\u5f8c\u8a66\u9a13\u3067\u5fc5\u9808\u306eJOIN\u3001\u30b5\u30d6\u30af\u30a8\u30ea\u3001\u96c6\u5408\u6f14\u7b97\u306e\u5b9f\u8df5\u30c6\u30af\u30cb\u30c3\u30af"},"content":{"rendered":"<p>\u7b2c1\u56de\u306e\u300eWindow\u95a2\u6570\u300f\u7de8\u3067\u306f\u30011\u3064\u306e\u7d50\u679c\u30bb\u30c3\u30c8\u5185\u3067\u9806\u4f4d\u4ed8\u3051\u3084\u79fb\u52d5\u5e73\u5747\u3068\u3044\u3063\u305f\u9ad8\u5ea6\u306a\u5206\u6790\u3092\u884c\u3046\u65b9\u6cd5\u3092\u5b66\u3073\u307e\u3057\u305f\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u5b9f\u969b\u306e\u696d\u52d9\u30c7\u30fc\u30bf\u306f\u3001\u95a2\u9023\u3059\u308b\u60c5\u5831\u304c\u8907\u6570\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u5206\u5272\u3055\u308c\u3066\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u306e\u304c\u4e00\u822c\u7684\u3067\u3059\u3002\u305d\u3053\u3067\u7b2c2\u56de\u3068\u306a\u308b\u4eca\u56de\u306f\u3001\u305d\u308c\u3089\u306e\u30c6\u30fc\u30d6\u30eb\u3092\u81ea\u5728\u306b<strong>\u300c\u7d50\u5408\u300d\u300c\u6bd4\u8f03\u300d\u300c\u7d44\u307f\u5408\u308f\u305b\u308b\u300d<\/strong>\u305f\u3081\u306e\u3001SQL\u4e2d\u7d1a\u8005\u4ee5\u4e0a\u3092\u76ee\u6307\u3059\u4e0a\u3067\u907f\u3051\u3066\u306f\u901a\u308c\u306a\u3044\u30c6\u30af\u30cb\u30c3\u30af\u3092\u5fb9\u5e95\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<p><code>INNER JOIN<\/code>\u3068\u306e\u9055\u3044\u304c\u7d1b\u3089\u3057\u3044<code>OUTER JOIN<\/code>\u3001<code>IN<\/code>\u3068<code>EXISTS<\/code>\u306e\u4f7f\u3044\u5206\u3051\u304c\u554f\u308f\u308c\u308b\u30b5\u30d6\u30af\u30a8\u30ea\u3001\u305d\u3057\u3066SQL\u3092\u5287\u7684\u306b\u6574\u7406\u3059\u308b<code>WITH<\/code>\u53e5\u307e\u3067\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30b9\u30da\u30b7\u30e3\u30ea\u30b9\u30c8\u8a66\u9a13\u306e\u5348\u5f8c\u554f\u984c\u3067\u983b\u51fa\u306e\u8ad6\u70b9\u3092\u7db2\u7f85\u3002\u3053\u308c\u3089\u306e\u6280\u8853\u3092\u30de\u30b9\u30bf\u30fc\u3059\u308c\u3070\u3001\u8907\u96d1\u306a\u8981\u4ef6\u306e\u30c7\u30fc\u30bf\u62bd\u51fa\u3082\u6050\u308c\u308b\u306b\u8db3\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u65e9\u901f\u3001\u30c6\u30fc\u30d6\u30eb\u7d50\u5408\u306e\u4e16\u754c\u3078\u9032\u3093\u3067\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>OUTER JOIN\u3092\u5b8c\u5168\u7406\u89e3\u2502INNER JOIN\u3068\u306e\u9055\u3044\u3068ON\u53e5\u306e\u91cd\u8981\u6027<\/h2>\n<p>\u30c6\u30fc\u30d6\u30eb\u7d50\u5408\u306e\u57fa\u672c\u3067\u3042\u308b<code>INNER JOIN<\/code>\u306f\u3001\u4e21\u65b9\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u5171\u901a\u3059\u308b\u30ad\u30fc\u304c\u5b58\u5728\u3059\u308b\u884c\u3060\u3051\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u3057\u304b\u3057\u3001\u5b9f\u52d9\u3067\u306f\u300c\u7247\u65b9\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u3057\u304b\u5b58\u5728\u3057\u306a\u3044\u30c7\u30fc\u30bf\u300d\u3082\u540c\u6642\u306b\u53d6\u5f97\u3057\u305f\u3044\u30b1\u30fc\u30b9\u304c\u983b\u7e41\u306b\u3042\u308a\u307e\u3059\u3002<\/p>\n<h3>\u3010\u601d\u8003\u30d7\u30ed\u30bb\u30b9\u3011\u306a\u305cINNER JOIN\u3060\u3051\u3067\u306f\u4e0d\u8db3\u306a\u306e\u304b\uff1f<\/h3>\n<p>\u4f8b\u3048\u3070\u3001<strong>\u5f93\u696d\u54e1<\/strong>\u30c6\u30fc\u30d6\u30eb\u3068<strong>\u90e8\u7f72<\/strong>\u30c6\u30fc\u30d6\u30eb\u304c\u3042\u308b\u3068\u3057\u307e\u3059\u3002\u3053\u306e2\u3064\u3092<code>INNER JOIN<\/code>\u3067\u7d50\u5408\u3059\u308b\u3068\u3001\u5fc5\u305a\u3069\u3053\u304b\u306e\u90e8\u7f72\u306b\u6240\u5c5e\u3057\u3066\u3044\u308b\u5f93\u696d\u54e1\u3057\u304b\u30ea\u30b9\u30c8\u30a2\u30c3\u30d7\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>\u3082\u3057\u300c<strong>\u307e\u3060\u3069\u306e\u90e8\u7f72\u306b\u3082\u914d\u5c5e\u3055\u308c\u3066\u3044\u306a\u3044\u65b0\u4eba\u5f93\u696d\u54e1<\/strong>\u300d\u3084\u3001\u300c<strong>\u8a2d\u7acb\u3055\u308c\u305f\u3070\u304b\u308a\u3067\u307e\u3060\u8ab0\u3082\u6240\u5c5e\u3057\u3066\u3044\u306a\u3044\u90e8\u7f72<\/strong>\u300d\u306e\u60c5\u5831\u3092\u53d6\u5f97\u3057\u305f\u3044\u5834\u5408\u3001<code>INNER JOIN<\/code>\u3067\u306f\u30c7\u30fc\u30bf\u304c\u6b20\u843d\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u3053\u306e\u8ab2\u984c\u3092\u89e3\u6c7a\u3059\u308b\u306e\u304c<code>OUTER JOIN<\/code>\uff08\u5916\u90e8\u7d50\u5408\uff09\u3067\u3059\u3002<\/p>\n<h3>OUTER JOIN\u306e\u7a2e\u985e\u3068\u30a4\u30e1\u30fc\u30b8<\/h3>\n<p><code>OUTER JOIN<\/code>\u306f\u3001\u57fa\u6e96\u3068\u306a\u308b\u30c6\u30fc\u30d6\u30eb\uff08\u4e3b\u30c6\u30fc\u30d6\u30eb\uff09\u306e\u884c\u3092\u3059\u3079\u3066\u6b8b\u3057\u3001\u305d\u3053\u306b\u3082\u3046\u7247\u65b9\u306e\u30c6\u30fc\u30d6\u30eb\u3092\u7d50\u5408\u3057\u307e\u3059\u3002\u3082\u3057\u76f8\u624b\u30c6\u30fc\u30d6\u30eb\u306b\u5bfe\u5fdc\u3059\u308b\u30c7\u30fc\u30bf\u304c\u306a\u3051\u308c\u3070\u3001\u305d\u306e\u5217\u306f<code>NULL<\/code>\u3068\u3057\u3066\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<table style=\"width: 100%; border-collapse: collapse;\" border=\"1\">\n<thead>\n<tr>\n<th style=\"padding: 8px; border: 1px solid #ddd;\">\u7a2e\u985e<\/th>\n<th style=\"padding: 8px; border: 1px solid #ddd;\">\u8aac\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding: 8px; border: 1px solid #ddd;\"><strong><code>LEFT OUTER JOIN<\/code><\/strong><\/td>\n<td style=\"padding: 8px; border: 1px solid #ddd;\"><strong>\u5de6\u5074<\/strong>\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u884c\u3092\u3059\u3079\u3066\u53d6\u5f97\u3059\u308b\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 8px; border: 1px solid #ddd;\"><strong><code>RIGHT OUTER JOIN<\/code><\/strong><\/td>\n<td style=\"padding: 8px; border: 1px solid #ddd;\"><strong>\u53f3\u5074<\/strong>\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u884c\u3092\u3059\u3079\u3066\u53d6\u5f97\u3059\u308b\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 8px; border: 1px solid #ddd;\"><strong><code>FULL OUTER JOIN<\/code><\/strong><\/td>\n<td style=\"padding: 8px; border: 1px solid #ddd;\"><strong>\u4e21\u65b9<\/strong>\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u884c\u3092\u3059\u3079\u3066\u53d6\u5f97\u3059\u308b\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e00\u822c\u7684\u306b\u3001<code>LEFT JOIN<\/code>\u304c\u6700\u3082\u3088\u304f\u4f7f\u308f\u308c\u307e\u3059\u3002\uff08<code>OUTER<\/code>\u306f\u7701\u7565\u53ef\u80fd\u3067\u3059\uff09<\/p>\n<h3>\u3010\u5177\u4f53\u4f8b\u3011INNER JOIN\u3068LEFT JOIN\u306e\u7d50\u679c\u306e\u9055\u3044<\/h3>\n<p><strong>\u30c6\u30fc\u30d6\u30eb\uff1a<code>employees<\/code><\/strong><\/p>\n<table style=\"width: 100%; border-collapse: collapse;\" border=\"1\">\n<thead>\n<tr>\n<th style=\"padding: 8px; border: 1px solid #ddd;\">id<\/th>\n<th style=\"padding: 8px; border: 1px solid #ddd;\">name<\/th>\n<th style=\"padding: 8px; border: 1px solid #ddd;\">dept_id<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding: 8px; border: 1px solid #ddd;\">1<\/td>\n<td style=\"padding: 8px; border: 1px solid #ddd;\">\u4f50\u85e4<\/td>\n<td style=\"padding: 8px; border: 1px solid #ddd;\">10<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 8px; border: 1px solid #ddd;\">2<\/td>\n<td style=\"padding: 8px; border: 1px solid #ddd;\">\u9234\u6728<\/td>\n<td style=\"padding: 8px; border: 1px solid #ddd;\">20<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 8px; border: 1px solid #ddd;\">3<\/td>\n<td style=\"padding: 8px; border: 1px solid #ddd;\">\u9ad8\u6a4b<\/td>\n<td style=\"padding: 8px; border: 1px solid #ddd;\">10<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 8px; border: 1px solid #ddd;\">4<\/td>\n<td style=\"padding: 8px; border: 1px solid #ddd;\">\u7530\u4e2d<\/td>\n<td style=\"padding: 8px; border: 1px solid #ddd;\"><code>NULL<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u30c6\u30fc\u30d6\u30eb\uff1a<code>departments<\/code><\/strong><\/p>\n<table style=\"width: 100%; border-collapse: collapse;\" border=\"1\">\n<thead>\n<tr>\n<th style=\"padding: 8px; border: 1px solid #ddd;\">id<\/th>\n<th style=\"padding: 8px; border: 1px solid #ddd;\">dept_name<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding: 8px; border: 1px solid #ddd;\">10<\/td>\n<td style=\"padding: 8px; border: 1px solid #ddd;\">\u55b6\u696d\u90e8<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 8px; border: 1px solid #ddd;\">20<\/td>\n<td style=\"padding: 8px; border: 1px solid #ddd;\">\u958b\u767a\u90e8<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 8px; border: 1px solid #ddd;\">30<\/td>\n<td style=\"padding: 8px; border: 1px solid #ddd;\">\u7dcf\u52d9\u90e8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4><code>INNER JOIN<\/code>\u306e\u5834\u5408<\/h4>\n<p>\u4e21\u65b9\u306e\u30c6\u30fc\u30d6\u30eb\u306b<code>dept_id<\/code>\u304c\u5b58\u5728\u3059\u308b\u884c\u3060\u3051\u304c\u7d50\u5408\u3055\u308c\u307e\u3059\u3002<code>dept_id<\/code>\u304c<code>NULL<\/code>\u306e\u7530\u4e2d\u3055\u3093\u3084\u3001\u8ab0\u3082\u6240\u5c5e\u3057\u3066\u3044\u306a\u3044\u7dcf\u52d9\u90e8\u306f\u7d50\u679c\u306b\u542b\u307e\u308c\u307e\u305b\u3093\u3002<\/p>\n<pre><code>SELECT e.name, d.dept_name\nFROM employees AS e\nINNER JOIN departments AS d ON e.dept_id = d.id;\n<\/code><\/pre>\n<h4><code>LEFT JOIN<\/code>\u306e\u5834\u5408<\/h4>\n<p><code>FROM<\/code>\u53e5\u3067\u6307\u5b9a\u3057\u305f\u5de6\u5074\u306e\u30c6\u30fc\u30d6\u30eb\uff08<code>employees<\/code>\uff09\u306e\u884c\u306f\u3059\u3079\u3066\u8868\u793a\u3055\u308c\u307e\u3059\u3002\u90e8\u7f72\u306b\u672a\u6240\u5c5e\u306e\u7530\u4e2d\u3055\u3093\u306e<code>dept_name<\/code>\u306f<code>NULL<\/code>\u3068\u3057\u3066\u53d6\u5f97\u3067\u304d\u3066\u3044\u308b\u70b9\u306b\u6ce8\u76ee\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><code>SELECT e.name, d.dept_name\nFROM employees AS e\nLEFT JOIN departments AS d ON e.dept_id = d.id;\n<\/code><\/pre>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001<code>OUTER JOIN<\/code>\u306f<strong>\u30de\u30b9\u30bf\u30c7\u30fc\u30bf\u306b\u5bfe\u3059\u308b\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u30c7\u30fc\u30bf\u306e\u6709\u7121\u3092\u78ba\u8a8d\u3059\u308b<\/strong>\u3068\u3044\u3063\u305f\u8981\u4ef6\u3067\u5fc5\u9808\u306e\u30c6\u30af\u30cb\u30c3\u30af\u3068\u306a\u308a\u307e\u3059\u3002\u7d50\u5408\u6761\u4ef6\u3092\u8a18\u8ff0\u3059\u308b<code>ON<\/code>\u53e5\u3068\u3001\u7d50\u5408\u7d50\u679c\u5168\u4f53\u304b\u3089\u3055\u3089\u306b\u884c\u3092\u7d5e\u308a\u8fbc\u3080<code>WHERE<\/code>\u53e5\u306e\u5f79\u5272\u306e\u9055\u3044\u3092\u610f\u8b58\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n<h2>\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u57fa\u672c\u3068\u5fdc\u7528\u2502IN, EXISTS, NOT EXISTS\u3092\u4f7f\u3044\u5206\u3051\u308b<\/h2>\n<p>\u30b5\u30d6\u30af\u30a8\u30ea\uff08\u526f\u554f\u5408\u305b\uff09\u306f\u3001\u305d\u306e\u540d\u306e\u901a\u308a\u300cSQL\u6587\u306e\u4e2d\u306b\u5165\u308c\u5b50\u3067\u8a18\u8ff0\u3059\u308b\u5225\u306eSQL\u6587\u300d\u306e\u3053\u3068\u3067\u3059\u3002<code>WHERE<\/code>\u53e5\u3084<code>FROM<\/code>\u53e5\u306a\u3069\u3067\u4f7f\u3044\u3001\u3088\u308a\u8907\u96d1\u306a\u6761\u4ef6\u3067\u306e\u30c7\u30fc\u30bf\u62bd\u51fa\u3092\u53ef\u80fd\u306b\u3057\u307e\u3059\u3002\u5348\u5f8c\u8a66\u9a13\u3067\u306f\u3001\u7279\u306b<code>IN<\/code>, <code>EXISTS<\/code>, <code>NOT EXISTS<\/code>\u306e\u9069\u5207\u306a\u4f7f\u3044\u5206\u3051\u304c\u554f\u308f\u308c\u307e\u3059\u3002<\/p>\n<h3><code>IN<\/code>: \u5024\u306e\u300c\u30ea\u30b9\u30c8\u300d\u306b\u542b\u307e\u308c\u308b\u304b\u3092\u5224\u5b9a<\/h3>\n<p><code>IN<\/code>\u306f\u3001\u30b5\u30d6\u30af\u30a8\u30ea\u304c\u8fd4\u3057\u305f<strong>\u7d50\u679c\u30bb\u30c3\u30c8\uff08\u5024\u306e\u30ea\u30b9\u30c8\uff09<\/strong>\u306b\u3001\u5bfe\u8c61\u306e\u5217\u306e\u5024\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<h4>\u3010\u5177\u4f53\u4f8b\u3011\u7279\u5b9a\u306e\u6761\u4ef6\u306b\u5408\u81f4\u3059\u308b\u90e8\u7f72\u306b\u6240\u5c5e\u3059\u308b\u5f93\u696d\u54e1\u3092\u62bd\u51fa<\/h4>\n<p>\u300c<strong>\u6771\u4eac\u672c\u793e<\/strong>\u306b\u6240\u5c5e\u3059\u308b\u5168\u90e8\u7f72\u306e\u5f93\u696d\u54e1\u4e00\u89a7\u300d\u3092\u53d6\u5f97\u3057\u305f\u3044\u5834\u5408\u3092\u8003\u3048\u307e\u3059\u3002\u307e\u305a\u30b5\u30d6\u30af\u30a8\u30ea\u3067\u300c\u6771\u4eac\u672c\u793e\u306e\u90e8\u7f72ID\u30ea\u30b9\u30c8\u300d\u3092\u53d6\u5f97\u3057\u3001\u305d\u306e\u30ea\u30b9\u30c8\u306b<code>dept_id<\/code>\u304c\u542b\u307e\u308c\u308b\u5f93\u696d\u54e1\u3092\u5916\u5074\u306e\u30af\u30a8\u30ea\u3067\u62bd\u51fa\u3057\u307e\u3059\u3002<\/p>\n<pre><code>SELECT\n  employee_name\nFROM\n  employees\nWHERE\n  dept_id IN ( -- \u3053\u3053\u304b\u3089\u30b5\u30d6\u30af\u30a8\u30ea\n    SELECT\n      dept_id\n    FROM\n      departments\n    WHERE\n      location = '\u6771\u4eac\u672c\u793e'\n  ); -- \u30b5\u30d6\u30af\u30a8\u30ea\u3053\u3053\u307e\u3067\n<\/code><\/pre>\n<p><code>IN<\/code>\u306f\u76f4\u611f\u7684\u3067\u5206\u304b\u308a\u3084\u3059\u3044\u3067\u3059\u304c\u3001\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u7d50\u679c\u30bb\u30c3\u30c8\u304c\u975e\u5e38\u306b\u5927\u304d\u304f\u306a\u308b\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u4f4e\u4e0b\u3059\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h3><code>EXISTS<\/code>: \u30c7\u30fc\u30bf\u304c\u300c\u5b58\u5728\u3059\u308b\u304b\u5426\u304b\u300d\u3092\u5224\u5b9a<\/h3>\n<p><code>EXISTS<\/code>\u306f\u3001\u30b5\u30d6\u30af\u30a8\u30ea\u304c<strong>1\u884c\u3067\u3082\u7d50\u679c\u3092\u8fd4\u305b\u3070TRUE\uff08\u771f\uff09<\/strong>\u30011\u884c\u3082\u8fd4\u3055\u306a\u3051\u308c\u3070<code>FALSE<\/code>\uff08\u507d\uff09\u3092\u8fd4\u3059\u6f14\u7b97\u5b50\u3067\u3059\u3002<code>IN<\/code>\u306e\u3088\u3046\u306b\u5024\u305d\u306e\u3082\u306e\u3092\u6bd4\u8f03\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u5358\u306b\u300c\u6761\u4ef6\u306b\u5408\u81f4\u3059\u308b\u884c\u304c\u5b58\u5728\u3059\u308b\u304b\u300d\u3060\u3051\u3092\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<p><code>EXISTS<\/code>\u3067\u306f\u3001\u5916\u5074\u306e\u30af\u30a8\u30ea\u306e\u5024\u3092\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u4e2d\u3067\u53c2\u7167\u3059\u308b<strong>\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea<\/strong>\u304c\u4f7f\u308f\u308c\u308b\u306e\u304c\u4e00\u822c\u7684\u3067\u3059\u3002<\/p>\n<pre><code>SELECT\n  e.employee_name\nFROM\n  employees AS e\nWHERE\n  EXISTS ( -- \u3053\u3053\u304b\u3089\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea\n    SELECT\n      1 -- \u4f55\u3092SELECT\u3057\u3066\u3082\u7d50\u679c\u306f\u540c\u3058\n    FROM\n      departments AS d\n    WHERE\n      d.dept_id = e.dept_id -- \u5916\u5074\u306e\u30c6\u30fc\u30d6\u30ebe\u3092\u53c2\u7167\n      AND d.location = '\u6771\u4eac\u672c\u793e'\n  );\n<\/code><\/pre>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306f\u6761\u4ef6\u306b\u5408\u3046\u884c\u30921\u4ef6\u898b\u3064\u3051\u305f\u77ac\u9593\u306b\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u8a55\u4fa1\u3092\u6253\u3061\u5207\u308c\u308b\u305f\u3081\u3001<code>IN<\/code>\u3088\u308a\u3082\u52b9\u7387\u7684\u306b\u52d5\u4f5c\u3059\u308b\u3053\u3068\u304c\u591a\u3044\u3067\u3059\u3002<\/p>\n<h3>\u3010\u983b\u51fa\u3011<code>NOT EXISTS<\/code>\u306b\u3088\u308b\u300c\u30a2\u30f3\u30c1\u30b8\u30e7\u30a4\u30f3\u300d<\/h3>\n<p><code>NOT EXISTS<\/code>\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30b9\u30da\u30b7\u30e3\u30ea\u30b9\u30c8\u8a66\u9a13\u3067\u7279\u306b\u91cd\u8981\u3067\u3059\u3002\u300c<strong>\uff5e\u306b\u5b58\u5728\u3057\u306a\u3044<\/strong>\u300d\u3068\u3044\u3046\u6761\u4ef6\u3092\u6307\u5b9a\u3059\u308b\u969b\u306b\u5a01\u529b\u3092\u767a\u63ee\u3057\u3001\u3053\u306e\u30d1\u30bf\u30fc\u30f3\u3092<strong>\u30a2\u30f3\u30c1\u30b8\u30e7\u30a4\u30f3<\/strong>\u3068\u547c\u3073\u307e\u3059\u3002<\/p>\n<h4>\u3010\u5177\u4f53\u4f8b\u3011\u5f93\u696d\u54e1\u304c\u4e00\u4eba\u3082\u6240\u5c5e\u3057\u3066\u3044\u306a\u3044\u90e8\u7f72\u3092\u62bd\u51fa<\/h4>\n<p><code>OUTER JOIN<\/code>\u3068<code>WHERE ... IS NULL<\/code>\u3067\u3082\u540c\u3058\u7d50\u679c\u3092\u5f97\u3089\u308c\u307e\u3059\u304c\u3001<code>NOT EXISTS<\/code>\u3092\u4f7f\u3046\u3068\u300c\uff5e\u3068\u3044\u3046\u6761\u4ef6\u3092\u6e80\u305f\u3059\u5f93\u696d\u54e1\u304c\u5b58\u5728\u3057\u306a\u3044\u90e8\u7f72\u300d\u3068\u3044\u3046\u610f\u56f3\u304cSQL\u3067\u660e\u78ba\u306b\u8868\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code>SELECT\n  d.dept_name\nFROM\n  departments AS d\nWHERE\n  NOT EXISTS ( -- \u3053\u306e\u90e8\u7f72ID\u3092\u6301\u3064\u5f93\u696d\u54e1\u304c\u5b58\u5728\u3057\u306a\u3044\n    SELECT\n      1\n    FROM\n      employees AS e\n    WHERE\n      e.dept_id = d.dept_id\n  );\n<\/code><\/pre>\n<p>\u3053\u306e<code>NOT EXISTS<\/code>\u3092\u4f7f\u3044\u3053\u306a\u305b\u308b\u304b\u306f\u3001SQL\u30b9\u30ad\u30eb\u306e\u4e00\u3064\u306e\u6307\u6a19\u3068\u306a\u308a\u307e\u3059\u3002\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u9762\u3067\u3082\u6709\u5229\u306a\u3053\u3068\u304c\u591a\u3044\u305f\u3081\u3001\u7a4d\u6975\u7684\u306b\u4f7f\u3048\u308b\u3088\u3046\u306b\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>\u554f\u3044\u5408\u308f\u305b\u7d50\u679c\u3092\u64cd\u4f5c\u3059\u308b\u96c6\u5408\u6f14\u7b97\u5b50\u2502UNION\u3068EXCEPT<\/h2>\n<p><code>JOIN<\/code>\u304c\u30c6\u30fc\u30d6\u30eb\u540c\u58eb\u3092<strong>\u6a2a\u65b9\u5411<\/strong>\u306b\u7d50\u5408\u3057\u3066\u5217\u3092\u5897\u3084\u3059\u306e\u306b\u5bfe\u3057\u3001\u96c6\u5408\u6f14\u7b97\u5b50\u306f\u8907\u6570\u306e<code>SELECT<\/code>\u6587\u306e\u7d50\u679c\u30bb\u30c3\u30c8\u3092<strong>\u7e26\u65b9\u5411<\/strong>\u306b\u9023\u7d50\u3057\u305f\u308a\u3001\u6bd4\u8f03\u3057\u305f\u308a\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u9055\u3044\u3092\u7406\u89e3\u3059\u308b\u3053\u3068\u304c\u3001\u96c6\u5408\u6f14\u7b97\u5b50\u3092\u30de\u30b9\u30bf\u30fc\u3059\u308b\u7b2c\u4e00\u6b69\u3067\u3059\u3002<\/p>\n<h3><code>JOIN<\/code>\u3068\u96c6\u5408\u6f14\u7b97\u5b50\u306e\u30a4\u30e1\u30fc\u30b8\u306e\u9055\u3044<\/h3>\n<ul>\n<li><strong><code>JOIN<\/code><\/strong>: \u30c6\u30fc\u30d6\u30ebA\u3068\u30c6\u30fc\u30d6\u30ebB\u3092\u30ad\u30fc\u3067\u7d10\u3065\u3051\u3001\u5217\u3092\u5897\u3084\u3059\u3002\uff08\u30d5\u30a1\u30b9\u30ca\u30fc\u3067\u670d\u3092\u9589\u3058\u308b\u30a4\u30e1\u30fc\u30b8\uff09<\/li>\n<li><strong>\u96c6\u5408\u6f14\u7b97\u5b50<\/strong>: \u30af\u30a8\u30eaA\u306e\u7d50\u679c\u3068\u30af\u30a8\u30eaB\u306e\u7d50\u679c\u3092\u3001\u7a4d\u307f\u6728\u306e\u3088\u3046\u306b\u7e26\u306b\u7a4d\u3093\u3060\u308a\u3001\u898b\u6bd4\u3079\u305f\u308a\u3059\u308b\u30a4\u30e1\u30fc\u30b8\u3002<\/li>\n<\/ul>\n<h3><code>UNION<\/code> \/ <code>UNION ALL<\/code>: \u7d50\u679c\u30bb\u30c3\u30c8\u306e\u548c\u96c6\u5408<\/h3>\n<p><code>UNION<\/code>\u306f\u30012\u3064\u4ee5\u4e0a\u306e<code>SELECT<\/code>\u6587\u306e\u7d50\u679c\u30921\u3064\u306b\u307e\u3068\u3081\u307e\u3059\u3002\u305d\u306e\u969b\u3001<strong>\u91cd\u8907\u3059\u308b\u884c\u306f\u81ea\u52d5\u7684\u306b\u6392\u9664<\/strong>\u3055\u308c\u307e\u3059\u3002\u3082\u3057\u91cd\u8907\u884c\u3082\u3059\u3079\u3066\u542b\u3081\u305f\u3044\u5834\u5408\u306f\u3001<code>UNION ALL<\/code>\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306f<code>UNION ALL<\/code>\u306e\u65b9\u304c\u9ad8\u901f\u3067\u3059\u3002<\/p>\n<h4>\u3010\u6ce8\u610f\u70b9\u3011<\/h4>\n<p><code>UNION<\/code>\u3067\u9023\u7d50\u3059\u308b\u5404<code>SELECT<\/code>\u6587\u306f\u3001<strong>\u5217\u306e\u6570\u3068\u5bfe\u5fdc\u3059\u308b\u30c7\u30fc\u30bf\u578b\u304c\u4e00\u81f4<\/strong>\u3057\u3066\u3044\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h4>\u3010\u5177\u4f53\u4f8b\u3011\u6771\u4eac\u652f\u793e\u3068\u5927\u962a\u652f\u793e\u306e\u5f93\u696d\u54e1\u30ea\u30b9\u30c8\u3092\u7d71\u5408\u3059\u308b<\/h4>\n<pre><code>-- \u6771\u4eac\u652f\u793e\u306e\u5f93\u696d\u54e1\nSELECT employee_id, employee_name FROM employees WHERE branch = '\u6771\u4eac';\nUNION\n-- \u5927\u962a\u652f\u793e\u306e\u5f93\u696d\u54e1\nSELECT employee_id, employee_name FROM employees WHERE branch = '\u5927\u962a';\n<\/code><\/pre>\n<p>\u3082\u3057\u4e21\u65b9\u306e\u652f\u793e\u306b\u91cd\u8907\u3057\u3066\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u5f93\u696d\u54e1\u304c\u3044\u305f\u5834\u5408\u3001<code>UNION<\/code>\u3067\u306f1\u540d\u3068\u3057\u3066\u96c6\u7d04\u3055\u308c\u3001<code>UNION ALL<\/code>\u3067\u306f2\u540d\u3068\u3057\u3066\u30ea\u30b9\u30c8\u30a2\u30c3\u30d7\u3055\u308c\u307e\u3059\u3002<\/p>\n<h3><code>EXCEPT<\/code>: \u7d50\u679c\u30bb\u30c3\u30c8\u306e\u5dee\u96c6\u5408<\/h3>\n<p><code>EXCEPT<\/code>\u306f\u3001\u6700\u521d\u306e<code>SELECT<\/code>\u6587\u306e\u7d50\u679c\u304b\u3089\u30012\u756a\u76ee\u306e<code>SELECT<\/code>\u6587\u306e\u7d50\u679c\u306b\u542b\u307e\u308c\u308b\u884c\u3092\u53d6\u308a\u9664\u3044\u305f\u5dee\u96c6\u5408\u3092\u8fd4\u3057\u307e\u3059\u3002\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u88fd\u54c1\u306b\u3088\u3063\u3066\u306f<code>MINUS<\/code>\u3068\u3044\u3046\u30ad\u30fc\u30ef\u30fc\u30c9\u3067\u5b9f\u88c5\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<h4>\u3010\u5177\u4f53\u4f8b\u3011\u300c\u512a\u826f\u9867\u5ba2\u300d\u3067\u306f\u306a\u3044\u300c\u6771\u4eac\u652f\u793e\u306e\u9867\u5ba2\u300d\u3092\u62bd\u51fa\u3059\u308b<\/h4>\n<p><code>NOT IN<\/code>\u3084<code>NOT EXISTS<\/code>\u3067\u3082\u4f3c\u305f\u3053\u3068\u306f\u53ef\u80fd\u3067\u3059\u304c\u30012\u3064\u306e\u30ea\u30b9\u30c8\u3092\u5358\u7d14\u306b\u6bd4\u8f03\u3057\u3066\u5dee\u5206\u3092\u6c42\u3081\u305f\u3044\u5834\u5408\u306f<code>EXCEPT<\/code>\u304c\u6700\u3082\u76f4\u611f\u7684\u3067\u3059\u3002<\/p>\n<pre><code>-- \u6771\u4eac\u652f\u793e\u306e\u5168\u9867\u5ba2\u30ea\u30b9\u30c8\nSELECT customer_id, customer_name FROM customers WHERE branch = '\u6771\u4eac';\nEXCEPT\n-- \u512a\u826f\u9867\u5ba2\u30ea\u30b9\u30c8\nSELECT customer_id, customer_name FROM premium_customers;\n<\/code><\/pre>\n<p>\u3053\u306e\u30af\u30a8\u30ea\u306f\u3001\u300c\u6771\u4eac\u652f\u793e\u306e\u9867\u5ba2\u3067\u306f\u3042\u308b\u304c\u3001\u512a\u826f\u9867\u5ba2\u30ea\u30b9\u30c8\u306b\u306f\u8f09\u3063\u3066\u3044\u306a\u3044\u9867\u5ba2\u300d\u3060\u3051\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<h3>\u305d\u306e\u4ed6\u306e\u96c6\u5408\u6f14\u7b97\u5b50<\/h3>\n<ul>\n<li><strong><code>INTERSECT<\/code><\/strong>: 2\u3064\u306e\u7d50\u679c\u30bb\u30c3\u30c8\u306e<strong>\u4e21\u65b9\u306b\u5b58\u5728\u3059\u308b\u884c\u306e\u307f<\/strong>\u3092\u8fd4\u3059\u7a4d\u96c6\u5408\u3067\u3059\u3002<\/li>\n<\/ul>\n<p>\u3053\u308c\u3089\u306e\u96c6\u5408\u6f14\u7b97\u5b50\u306f\u3001\u8907\u6570\u306e\u6761\u4ef6\u3067\u62bd\u51fa\u3057\u305f\u7d50\u679c\u3092\u52a0\u5de5\u30fb\u6574\u5f62\u3059\u308b\u969b\u306b\u5f37\u529b\u306a\u30c4\u30fc\u30eb\u3068\u306a\u308a\u307e\u3059\u3002\u7279\u306b<code>EXCEPT<\/code>\u306f\u30c7\u30fc\u30bf\u30af\u30ec\u30f3\u30b8\u30f3\u30b0\u3084\u5dee\u5206\u30c1\u30a7\u30c3\u30af\u306a\u3069\u3067\u5f79\u7acb\u3061\u307e\u3059\u3002<\/p>\n<h2>SQL\u3092\u5287\u7684\u306b\u898b\u3084\u3059\u304f\u3059\u308bWITH\u53e5\uff08CTE\uff09\u306e\u4f7f\u3044\u65b9<\/h2>\n<p>\u8907\u96d1\u306aSQL\u3092\u8a18\u8ff0\u3057\u3066\u3044\u308b\u3068\u3001\u30b5\u30d6\u30af\u30a8\u30ea\u304c\u4f55\u91cd\u306b\u3082\u30cd\u30b9\u30c8\uff08\u5165\u308c\u5b50\uff09\u3057\u3066\u3057\u307e\u3044\u3001\u89e3\u8aad\u304c\u56f0\u96e3\u306b\u306a\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<code>WITH<\/code>\u53e5\uff08\u5171\u901a\u30c6\u30fc\u30d6\u30eb\u5f0f\uff1aCommon Table Expression\uff09\u306f\u3001\u3053\u306e\u3088\u3046\u306aSQL\u3092\u5287\u7684\u306b\u8aad\u307f\u3084\u3059\u304f\u3001\u6574\u7406\u3059\u308b\u305f\u3081\u306e\u5f37\u529b\u306a\u6a5f\u80fd\u3067\u3059\u3002<\/p>\n<p><code>WITH<\/code>\u53e5\u3092\u4f7f\u3046\u3068\u3001\u30b5\u30d6\u30af\u30a8\u30ea\u306b<strong>\u4e00\u6642\u7684\u306a\u540d\u524d<\/strong>\u3092\u4ed8\u3051\u3066\u3001\u30e1\u30a4\u30f3\u306eSQL\u6587\u306e\u524d\u306b\u5b9a\u7fa9\u3057\u3066\u304a\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>\u3010\u30e1\u30ea\u30c3\u30c8\u3011\u53ef\u8aad\u6027\u3068\u518d\u5229\u7528\u6027\u306e\u5411\u4e0a<\/h3>\n<ul>\n<li><strong>\u53ef\u8aad\u6027<\/strong>: \u51e6\u7406\u306e\u30b9\u30c6\u30c3\u30d7\u3054\u3068\u306b\u540d\u524d\u3092\u4ed8\u3051\u3066\u5206\u5272\u3067\u304d\u308b\u305f\u3081\u3001\u4e0a\u304b\u3089\u9806\u306b\u30ed\u30b8\u30c3\u30af\u3092\u8ffd\u3044\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/li>\n<li><strong>\u518d\u5229\u7528\u6027<\/strong>: \u4e00\u5ea6\u5b9a\u7fa9\u3057\u305f\u4e00\u6642\u30c6\u30fc\u30d6\u30eb\u306f\u3001\u5f8c\u7d9a\u306e\u30af\u30a8\u30ea\u3067\u4f55\u5ea6\u3082\u53c2\u7167\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ul>\n<h3>\u3010\u5177\u4f53\u4f8b\u3011\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u30cd\u30b9\u30c8\u3092WITH\u53e5\u3067\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0<\/h3>\n<p>\u4f8b\u3048\u3070\u3001\u300c<strong>\u5404\u90e8\u7f72\u306e\u5e73\u5747\u7d66\u4e0e\u3092\u7b97\u51fa\u3057\u3001\u305d\u306e\u5e73\u5747\u7d66\u4e0e\u3088\u308a\u3082\u9ad8\u3044\u7d66\u4e0e\u3092\u3082\u3089\u3063\u3066\u3044\u308b\u5f93\u696d\u54e1\u3092\u30ea\u30b9\u30c8\u30a2\u30c3\u30d7\u3059\u308b<\/strong>\u300d\u3068\u3044\u3046\u8981\u4ef6\u3092\u8003\u3048\u307e\u3059\u3002<\/p>\n<h4><code>WITH<\/code>\u53e5\u3092\u4f7f\u308f\u306a\u3044\u5834\u5408<\/h4>\n<p><code>FROM<\/code>\u53e5\u306e\u4e2d\u306b\u30b5\u30d6\u30af\u30a8\u30ea\u3092\u8a18\u8ff0\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u3001\u3069\u306e\u90e8\u5206\u304c\u4f55\u3092\u3057\u3066\u3044\u308b\u306e\u304b\u4e00\u898b\u3057\u3066\u5206\u304b\u308a\u306b\u304f\u3044\u3067\u3059\u3002<\/p>\n<pre><code>SELECT\n  e.employee_name,\n  e.salary,\n  dept_avg.avg_salary AS department_average\nFROM\n  employees AS e\n  INNER JOIN (\n    -- \u3053\u3053\u304c\u30b5\u30d6\u30af\u30a8\u30ea\u3002\u90e8\u7f72\u3054\u3068\u306e\u5e73\u5747\u7d66\u4e0e\u3092\u7b97\u51fa\n    SELECT\n      dept_id,\n      AVG(salary) AS avg_salary\n    FROM\n      employees\n    GROUP BY\n      dept_id\n  ) AS dept_avg ON e.dept_id = dept_avg.dept_id\nWHERE\n  e.salary &gt; dept_avg.avg_salary; -- \u90e8\u7f72\u5e73\u5747\u3088\u308a\u9ad8\u3044\u7d66\u4e0e\u306e\u5f93\u696d\u54e1\u3092\u7d5e\u308a\u8fbc\u307f\n<\/code><\/pre>\n<h4><code>WITH<\/code>\u53e5\u3092\u4f7f\u3063\u305f\u5834\u5408<\/h4>\n<p>\u307e\u305a\u300c\u90e8\u7f72\u3054\u3068\u306e\u5e73\u5747\u7d66\u4e0e\u7b97\u51fa\u300d\u3068\u3044\u3046\u51e6\u7406\u3092<code>dept_avg_cte<\/code>\u3068\u3044\u3046\u540d\u524d\u3067\u5b9a\u7fa9\u3057\u307e\u3059\u3002\u30e1\u30a4\u30f3\u306e<code>SELECT<\/code>\u6587\u3067\u306f\u3001\u305d\u306e\u540d\u524d\u3092\u4ed8\u3051\u305f\u4e00\u6642\u30c6\u30fc\u30d6\u30eb\u3092\u53c2\u7167\u3059\u308b\u3060\u3051\u306a\u306e\u3067\u3001\u69cb\u9020\u304c\u975e\u5e38\u306b\u30b7\u30f3\u30d7\u30eb\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code>-- \u307e\u305a\u300c\u90e8\u7f72\u3054\u3068\u306e\u5e73\u5747\u7d66\u4e0e\u300d\u3068\u3044\u3046\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\u3092\u300cdept_avg_cte\u300d\u3068\u3057\u3066\u5b9a\u7fa9\nWITH dept_avg_cte AS (\n  SELECT\n    dept_id,\n    AVG(salary) AS avg_salary\n  FROM\n    employees\n  GROUP BY\n    dept_id\n)\n-- \u4e0a\u3067\u5b9a\u7fa9\u3057\u305f\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\u3092\u4f7f\u3063\u3066\u3001\u30e1\u30a4\u30f3\u306e\u51e6\u7406\u3092\u8a18\u8ff0\nSELECT\n  e.employee_name,\n  e.salary,\n  d.avg_salary AS department_average\nFROM\n  employees AS e\n  INNER JOIN dept_avg_cte AS d ON e.dept_id = d.dept_id\nWHERE\n  e.salary &gt; d.avg_salary;\n<\/code><\/pre>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001<code>WITH<\/code>\u53e5\u306f\u8907\u96d1\u306a\u51e6\u7406\u3092\u610f\u5473\u306e\u3042\u308b\u5358\u4f4d\u3067\u90e8\u54c1\u5316\u3057\u3001SQL\u5168\u4f53\u306e\u53ef\u8aad\u6027\u3092\u98db\u8e8d\u7684\u306b\u9ad8\u3081\u307e\u3059\u3002\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30b9\u30da\u30b7\u30e3\u30ea\u30b9\u30c8\u306e\u5348\u5f8c\u8a66\u9a13\u3067\u9577\u6587SQL\u3092\u8a18\u8ff0\u30fb\u8aad\u89e3\u3059\u308b\u969b\u306b\u306f\u5fc5\u9808\u306e\u30c6\u30af\u30cb\u30c3\u30af\u3067\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u5fdc\u7528\u3068\u3057\u3066<code>WITH RECURSIVE<\/code>\u3092\u4f7f\u3046\u3068\u3001\u7d44\u7e54\u56f3\u306e\u3088\u3046\u306a\u968e\u5c64\u69cb\u9020\u30c7\u30fc\u30bf\u3092\u6271\u3046\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h2>\u307e\u3068\u3081\uff1a\u7d50\u5408\u3068\u96c6\u5408\u3092\u5236\u3057\u3066\u3001\u8907\u96d1\u306a\u30c7\u30fc\u30bf\u62bd\u51fa\u3092\u81ea\u5728\u306b\u64cd\u308b<\/h2>\n<p>\u4eca\u56de\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30b9\u30da\u30b7\u30e3\u30ea\u30b9\u30c8\u8a66\u9a13\u306e\u5348\u5f8c\u554f\u984c\u3067\u983b\u51fa\u306e\u300c\u30c6\u30fc\u30d6\u30eb\u7d50\u5408\u300d\u300c\u30b5\u30d6\u30af\u30a8\u30ea\u300d\u300c\u96c6\u5408\u6f14\u7b97\u300d\u3068\u3044\u3063\u305f\u3001\u8907\u6570\u306e\u30c7\u30fc\u30bf\u3092\u6271\u3046\u305f\u3081\u306e\u5fc5\u9808\u30c6\u30af\u30cb\u30c3\u30af\u3092\u89e3\u8aac\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u308c\u305e\u308c\u306e\u69cb\u6587\u306f\u76ee\u7684\u304c\u660e\u78ba\u306b\u7570\u306a\u308a\u307e\u3059\u3002\u3069\u306e\u5834\u9762\u3067\u4f55\u3092\u4f7f\u3046\u3079\u304d\u304b\u3001\u982d\u306e\u4e2d\u3092\u6574\u7406\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<ul>\n<li><strong><code>OUTER JOIN<\/code><\/strong>: <strong>\u30c7\u30fc\u30bf\u304c\u6b20\u843d\u3057\u306a\u3044\u3088\u3046\u306b<\/strong>\u30c6\u30fc\u30d6\u30eb\u3092\u6a2a\u306b\u7d50\u5408\u3057\u305f\u3044\u3068\u304d\u306b\u4f7f\u3046\u3002<code>NULL<\/code>\u3092\u8a31\u5bb9\u3059\u308b\u3053\u3068\u3067\u3001\u4e3b\u30c6\u30fc\u30d6\u30eb\u306e\u60c5\u5831\u3092\u3059\u3079\u3066\u4fdd\u6301\u3059\u308b\u306e\u304c\u76ee\u7684\u3002<\/li>\n<li><strong>\u30b5\u30d6\u30af\u30a8\u30ea (<code>IN<\/code>, <code>EXISTS<\/code>)<\/strong>: \u3042\u308b\u554f\u3044\u5408\u308f\u305b\u7d50\u679c\u3092<strong>\u6761\u4ef6\u3068\u3057\u3066<\/strong>\u3001\u5225\u306e\u554f\u3044\u5408\u308f\u305b\u3092\u884c\u3044\u305f\u3044\u3068\u304d\u306b\u4f7f\u3046\u3002\u7279\u306b<code>NOT EXISTS<\/code>\u306f\u300c\uff5e\u306a\u3044\u3082\u306e\u3092\u63a2\u3059\u300d\u30a2\u30f3\u30c1\u30b8\u30e7\u30a4\u30f3\u306e\u578b\u3068\u3057\u3066\u975e\u5e38\u306b\u5f37\u529b\u3002<\/li>\n<li><strong>\u96c6\u5408\u6f14\u7b97\u5b50 (<code>UNION<\/code>, <code>EXCEPT<\/code>)<\/strong>: 2\u3064\u4ee5\u4e0a\u306e\u554f\u3044\u5408\u308f\u305b<strong>\u7d50\u679c\u305d\u306e\u3082\u306e<\/strong>\u3092\u3001\u7e26\u306b\u9023\u7d50\u3057\u305f\u308a\uff08\u548c\u96c6\u5408\uff09\u3001\u5dee\u3057\u5f15\u3044\u305f\u308a\uff08\u5dee\u96c6\u5408\uff09\u3057\u305f\u3044\u3068\u304d\u306b\u4f7f\u3046\u3002<\/li>\n<li><strong><code>WITH<\/code>\u53e5 (CTE)<\/strong>: \u4e0a\u8a18\u3092\u542b\u3080\u8907\u96d1\u306aSQL\u6587\u306e<strong>\u53ef\u8aad\u6027\u3092\u9ad8\u3081\u305f\u3044<\/strong>\u3068\u304d\u306b\u4f7f\u3046\u3002\u51e6\u7406\u306e\u30b9\u30c6\u30c3\u30d7\u3092\u90e8\u54c1\u5316\u3057\u3001\u5168\u4f53\u306e\u30ed\u30b8\u30c3\u30af\u3092\u660e\u78ba\u306b\u3059\u308b\u305f\u3081\u306e\u6b66\u5668\u3002<\/li>\n<\/ul>\n<p>\u3053\u308c\u3089\u306e\u30c6\u30af\u30cb\u30c3\u30af\u3092\u81ea\u5728\u306b\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u5348\u5f8c\u8a66\u9a13\u3067\u8981\u6c42\u3055\u308c\u308b\u8907\u96d1\u306a\u30c7\u30fc\u30bf\u62bd\u51fa\u8981\u4ef6\u306e\u307b\u3068\u3093\u3069\u306b\u5bfe\u5fdc\u3067\u304d\u307e\u3059\u3002\u307e\u305a\u306f\u305d\u308c\u305e\u308c\u306e\u5f79\u5272\u3092\u6b63\u78ba\u306b\u7406\u89e3\u3057\u3001\u7c21\u5358\u306aSQL\u304b\u3089\u3067\u3082\u5b9f\u969b\u306b\u66f8\u3044\u3066\u8a66\u3057\u3066\u307f\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n<p>\u6b21\u56de\u306f\u3001\u3044\u3088\u3044\u3088\u3053\u306e\u9023\u8f09\u306e\u6700\u7d42\u56de\u3068\u306a\u308b<strong>\u300e\u7b2c3\u56de\uff1aSQL\u5fdc\u7528\u30c6\u30af\u30cb\u30c3\u30af\u96c6\uff01\u30ab\u30fc\u30bd\u30eb\u30fb\u4fbf\u5229\u95a2\u6570\u30fb\u5236\u7d04\u5b9a\u7fa9\u7de8\u300f<\/strong>\u3092\u304a\u5c4a\u3051\u3057\u307e\u3059\u3002<code>CASE<\/code>\u5f0f\u3084<code>COALESCE<\/code>\u95a2\u6570\u306a\u3069\u3001\u77e5\u3063\u3066\u3044\u308b\u3068\u5dee\u304c\u4ed8\u304f\u5b9f\u7528\u7684\u306a\u30c6\u30af\u30cb\u30c3\u30af\u3092\u89e3\u8aac\u3057\u307e\u3059\u306e\u3067\u3001\u3054\u671f\u5f85\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7b2c1\u56de\u306e\u300eWindow\u95a2\u6570\u300f\u7de8\u3067\u306f\u30011\u3064\u306e\u7d50\u679c\u30bb\u30c3\u30c8\u5185\u3067\u9806\u4f4d\u4ed8\u3051\u3084\u79fb\u52d5\u5e73\u5747\u3068\u3044\u3063\u305f\u9ad8\u5ea6\u306a\u5206\u6790\u3092\u884c\u3046\u65b9\u6cd5\u3092\u5b66\u3073\u307e\u3057\u305f\u3002 \u3057\u304b\u3057\u3001\u5b9f\u969b\u306e\u696d\u52d9\u30c7\u30fc\u30bf\u306f\u3001\u95a2\u9023\u3059\u308b\u60c5\u5831\u304c\u8907\u6570\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u5206\u5272\u3055\u308c\u3066\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b &#8230; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","columnck":"","stmeta_robots":"index, follow","st_titlewords":"","st_title_extra":"","st_keywords":"","st_description":"","st_display_ad_mark":"","st_display_ad_mark_hide":"","textcopyck":"","st_copyright":"","st_copyurl":"","eyecatch_set":"","st_youtube_url":"","st_youtube_eyecatch":"","headerwidget_set":"","updatewidget_set":"","kanrenwidget_set":"","ikkatuwidget_set":"","koukoku_set":"","auto_adsense_koukoku_set":"","st_redirect":"","st_redirect_url_as_canonical":"","st_redirect_pvm_do_not_track":"","post_data_updatewidget_set":"","st_post_header_under_bg":"","st_twitter_tag":"","affinger_note":"","rankdisplayck":"","st_head_code":"","st_footer_code":"","st_post_header_under_code":"","_st_toc_override":false,"_st_toc_settings":[]},"categories":[3],"tags":[6],"class_list":["post-5922","post","type-post","status-publish","format-standard","hentry","category-ipa","tag-6"],"_links":{"self":[{"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/posts\/5922","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/comments?post=5922"}],"version-history":[{"count":0,"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/posts\/5922\/revisions"}],"wp:attachment":[{"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/media?parent=5922"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/categories?post=5922"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/tags?post=5922"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}