{"id":6154,"date":"2025-10-07T08:57:18","date_gmt":"2025-10-06T23:57:18","guid":{"rendered":"https:\/\/sky-peace.net\/?p=6154"},"modified":"2025-10-07T08:57:18","modified_gmt":"2025-10-06T23:57:18","slug":"ap-q-h30-db","status":"publish","type":"post","link":"https:\/\/sky-peace.net\/certified\/ap-q-h30-db\/","title":{"rendered":"\u5fdc\u7528\u60c5\u5831H30\u79cb\u300c\u5165\u5ba4\u7ba1\u7406\u30b7\u30b9\u30c6\u30e0\u300d\u3092\u5b8c\u5168\u653b\u7565\uff1aER\u56f3\u30fb\u8907\u5408\u30ad\u30fc\u30fbCOUNT\u5224\u5b9a\u30fb\u81ea\u5df1\u7d50\u5408\u3092\u7dcf\u5408\u89e3\u8aac"},"content":{"rendered":"<p>\u5fdc\u7528\u60c5\u5831\u6280\u8853\u8005\u8a66\u9a13\u306e\u5348\u5f8c\u554f\u984c\u3001\u305d\u306e\u4e2d\u3067\u3082\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u5206\u91ce\u306f\u3001\u591a\u304f\u306e\u53d7\u9a13\u8005\u304c\u82e6\u6226\u3059\u308b\u4e00\u65b9\u3067\u3001\u5b9f\u52d9\u306b\u76f4\u7d50\u3059\u308b\u91cd\u8981\u306a\u77e5\u8b58\u304c\u554f\u308f\u308c\u308b\u9818\u57df\u3067\u3059\u3002\u7279\u306b\u5e73\u621030\u5e74\u79cb\u5b63\u306e\u554f2\u300c\u5165\u5ba4\u7ba1\u7406\u30b7\u30b9\u30c6\u30e0\u300d\u306f\u3001\u5358\u306a\u308bSQL\u306e\u77e5\u8b58\u3060\u3051\u3067\u306f\u89e3\u3051\u306a\u3044\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u201d\u306a\u305c\u201d\u3092\u6df1\u304f\u7406\u89e3\u3057\u3066\u3044\u308b\u304b\u304c\u8a66\u3055\u308c\u308b\u540d\u4f5c\u554f\u984c\u3068\u8a00\u3048\u308b\u3067\u3057\u3087\u3046\u3002ER\u56f3\u306e\u7dda\u306e\u610f\u5473\u304b\u3089\u3001\u8907\u5408\u4e3b\u30ad\u30fc\u306e\u5b58\u5728\u7406\u7531\u3001COUNT\u95a2\u6570\u3092\u4f7f\u3063\u305f\u5de7\u5999\u306a\u6761\u4ef6\u5224\u5b9a\u3001\u305d\u3057\u3066\u81ea\u5df1\u7d50\u5408\u306b\u3088\u308b\u968e\u5c64\u69cb\u9020\u306e\u5c55\u958b\u307e\u3067\u3001\u5185\u5bb9\u306f\u591a\u5c90\u306b\u308f\u305f\u308a\u307e\u3059\u3002\u672c\u8a18\u4e8b\u3067\u306f\u3001\u3053\u306e\u300c\u5165\u5ba4\u7ba1\u7406\u30b7\u30b9\u30c6\u30e0\u300d\u3092\u984c\u6750\u306b\u3001\u5404\u8a2d\u554f\u306e\u80cc\u5f8c\u306b\u3042\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u539f\u7406\u539f\u5247\u3092\u4e00\u3064\u3072\u3068\u3064\u4e01\u5be7\u306b\u89e3\u304d\u660e\u304b\u3057\u3066\u3044\u304d\u307e\u3059\u3002\u300c\u306a\u3093\u3068\u306a\u304f\u6b63\u89e3\u3067\u304d\u305f\u300d\u304b\u3089\u300c\u8ad6\u7406\u7684\u306b\u8aac\u660e\u3067\u304d\u308b\u300d\u30ec\u30d9\u30eb\u3078\u5f15\u304d\u4e0a\u3052\u308b\u3053\u3068\u3092\u76ee\u6a19\u306b\u3001\u8c4a\u5bcc\u306a\u56f3\u89e3\u3068\u5177\u4f53\u4f8b\u3092\u4ea4\u3048\u306a\u304c\u3089\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u8a2d\u8a08\u3068SQL\u64cd\u4f5c\u306e\u6838\u5fc3\u3092\u5b8c\u5168\u653b\u7565\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>\u8a2d\u554f\u2460\u5fb9\u5e95\u89e3\u8aac\uff1aER\u56f3\u306e\u7dda\u304c\u793a\u3059\u300c\u53c2\u7167\u6574\u5408\u6027\u300d\u3068\u5916\u90e8\u30ad\u30fc\u306e\u5f79\u5272<\/h2>\n<p>\u5fdc\u7528\u60c5\u5831\u6280\u8853\u8005\u8a66\u9a13\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u554f\u984c\u3067\u306f\u3001\u6700\u521d\u306bER\u56f3\uff08\u5b9f\u4f53\u95a2\u9023\u56f3\uff09\u306e\u8aad\u89e3\u304c\u6c42\u3081\u3089\u308c\u308b\u3053\u3068\u304c\u983b\u7e41\u306b\u3042\u308a\u307e\u3059\u3002\u8a2d\u554f1\u306f\u3001\u307e\u3055\u306b\u305d\u306e\u8aad\u89e3\u529b\u3092\u8a66\u3059\u554f\u984c\u3067\u3057\u305f\u3002\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u9593\u3092\u7d50\u3076\u300c\u7dda\u300d\u304c\u4e00\u4f53\u4f55\u3092\u610f\u5473\u3059\u308b\u306e\u304b\u3001\u305d\u306e\u672c\u8cea\u3092\u7406\u89e3\u3059\u308b\u3053\u3068\u304c\u653b\u7565\u306e\u9375\u3067\u3059\u3002\u7d50\u8ad6\u304b\u3089\u8a00\u3046\u3068\u3001<strong>ER\u56f3\u306e\u7dda\u306f\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u9593\u306e\u300c\u53c2\u7167\u95a2\u4fc2\u300d\u3001\u3064\u307e\u308a\u5916\u90e8\u30ad\u30fc\u306b\u3088\u308b\u30c6\u30fc\u30d6\u30eb\u306e\u7e4b\u304c\u308a<\/strong>\u3092\u8868\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>\u7dda\u3092\u5f15\u304f\u306e\u306f\u300c\u5916\u90e8\u30ad\u30fc\u300d\u304c\u5b58\u5728\u3059\u308b\u3068\u304d\u3060\u3051<\/h3>\n<p>ER\u56f3\u306b\u63cf\u304b\u308c\u308b\u5b9f\u7dda\u3084\u7834\u7dda\u306f\u3001\u5358\u306a\u308b\u95a2\u9023\u6027\u3092\u793a\u5506\u3059\u308b\u3082\u306e\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u3053\u308c\u306f\u3001\u4e00\u65b9\u306e\u30c6\u30fc\u30d6\u30eb\uff08\u5b50\u30c6\u30fc\u30d6\u30eb\uff09\u304c\u3001\u3082\u3046\u4e00\u65b9\u306e\u30c6\u30fc\u30d6\u30eb\uff08\u89aa\u30c6\u30fc\u30d6\u30eb\uff09\u306e\u4e3b\u30ad\u30fc\u3092\u300c\u5916\u90e8\u30ad\u30fc\u300d\u3068\u3057\u3066\u81ea\u8eab\u306e\u5217\u306b\u4fdd\u6301\u3057\u3001\u305d\u308c\u306b\u3088\u3063\u3066\u30c7\u30fc\u30bf\u306e\u6574\u5408\u6027\u3092\u62c5\u4fdd\u3057\u3066\u3044\u308b\u72b6\u614b\uff08\u53c2\u7167\u6574\u5408\u6027\u5236\u7d04\uff09\u3092\u660e\u793a\u3059\u308b\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u4eca\u56de\u306e\u554f\u984c\u306b\u304a\u3051\u308b\u300c\u793e\u54e1\u300d\u30c6\u30fc\u30d6\u30eb\u3068\u300c\u5165\u5ba4\u8a31\u53ef\u300d\u30c6\u30fc\u30d6\u30eb\u306e\u95a2\u4fc2\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>\n\u3010\u793e\u54e1\u30c6\u30fc\u30d6\u30eb\u3011\n\u793e\u54e1ID (\u4e3b\u30ad\u30fc), ...\n\n\u3010\u5165\u5ba4\u8a31\u53ef\u30c6\u30fc\u30d6\u30eb\u3011\n\u793e\u54e1ID (\u5916\u90e8\u30ad\u30fc), \u5ba4ID (\u5916\u90e8\u30ad\u30fc), ...\n<\/pre>\n<p>\u300c\u5165\u5ba4\u8a31\u53ef\u300d\u30c6\u30fc\u30d6\u30eb\u306f\u3001\u3069\u306e\u793e\u54e1\u306b\u8a31\u53ef\u3092\u4e0e\u3048\u308b\u304b\u3092\u793a\u3059\u305f\u3081\u306b\u300c\u793e\u54e1ID\u300d\u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u300c\u793e\u54e1ID\u300d\u306f\u3001\u300c\u793e\u54e1\u300d\u30c6\u30fc\u30d6\u30eb\u306b\u5b9f\u969b\u306b\u5b58\u5728\u3059\u308b\u793e\u54e1ID\u3067\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002\u3053\u306e\u5236\u7d04\u304c\u3042\u308b\u304b\u3089\u3053\u305d\u3001\u4e21\u30c6\u30fc\u30d6\u30eb\u3092\u7dda\u3067\u7d50\u3076\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u3067\u3059\u3002<\/p>\n<p>\u8eab\u8fd1\u306a\u4f8b\u3067\u8a00\u3048\u3070\u3001\u3053\u308c\u306f\u30b9\u30de\u30fc\u30c8\u30d5\u30a9\u30f3\u306e\u96fb\u8a71\u5e33\u3068\u30e1\u30c3\u30bb\u30fc\u30b8\u30a2\u30d7\u30ea\u306e\u95a2\u4fc2\u306b\u4f3c\u3066\u3044\u307e\u3059\u3002\u30e1\u30c3\u30bb\u30fc\u30b8\u30a2\u30d7\u30ea\u3067\u3084\u308a\u53d6\u308a\u3059\u308b\u76f8\u624b\u306f\u3001\u5fc5\u305a\u96fb\u8a71\u5e33\u306b\u767b\u9332\u3055\u308c\u3066\u3044\u308b\uff08\u3042\u308b\u3044\u306f\u4e00\u6642\u7684\u306b\u756a\u53f7\u304c\u8a18\u9332\u3055\u308c\u3066\u3044\u308b\uff09\u4eba\u7269\u3067\u3059\u3088\u306d\u3002\u5b58\u5728\u3057\u306a\u3044\u76f8\u624b\u306b\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u9001\u308c\u306a\u3044\u3088\u3046\u306b\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u3082<strong>\u89aa\u30c6\u30fc\u30d6\u30eb\u306b\u5b58\u5728\u3057\u306a\u3044\u30c7\u30fc\u30bf\u3092\u53c2\u7167\u3059\u308b\u5b50\u30c6\u30fc\u30d6\u30eb\u306e\u884c\u306f\u4f5c\u6210\u3067\u304d\u306a\u3044<\/strong>\u3001\u3068\u3044\u3046\u30eb\u30fc\u30eb\u304c\u3053\u306e\u300c\u7dda\u300d\u306b\u3088\u3063\u3066\u4fdd\u8a3c\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>\u300c\u5165\u5ba4\u8a31\u53ef\u300d\u3068\u300c\u5165\u9000\u5ba4\u30ed\u30b0\u300d\u304c\u76f4\u63a5\u7d50\u3070\u306a\u3044\u7406\u7531<\/h3>\n<p>\u3067\u306f\u3001\u306a\u305c\u554f\u984c\u306eER\u56f3\u3067\u306f\u300c\u5165\u5ba4\u8a31\u53ef\u300d\u3068\u300c\u5165\u9000\u5ba4\u30ed\u30b0\u300d\u304c\u76f4\u63a5\u7dda\u3067\u7d50\u3070\u308c\u3066\u3044\u306a\u3044\u306e\u3067\u3057\u3087\u3046\u304b\u3002\u4e00\u898b\u3059\u308b\u3068\u3001\u300c\u8a31\u53ef\u3055\u308c\u305f\u4eba\u304c\u30ed\u30b0\u3092\u6b8b\u3059\u300d\u306e\u3060\u304b\u3089\u95a2\u4fc2\u304c\u3042\u308a\u305d\u3046\u306b\u601d\u3048\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u304c\u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\u3067\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u8a2d\u8a08\u3067\u306f<strong>\u300c\u30c7\u30fc\u30bf\u3068\u3057\u3066\u76f4\u63a5\u53c2\u7167\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u304b\u300d<\/strong>\u3068\u3044\u3046\u89b3\u70b9\u3067\u306e\u307f\u7dda\u3092\u5f15\u304d\u307e\u3059\u3002\u4e21\u8005\u306e\u95a2\u4fc2\u3092\u6574\u7406\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<table border=\"1\" style=\"width:100%; border-collapse: collapse;\">\n<thead>\n<tr>\n<th style=\"padding: 8px; background-color: #f2f2f2;\">\u30c6\u30fc\u30d6\u30eb<\/th>\n<th style=\"padding: 8px; background-color: #f2f2f2;\">\u4fdd\u6301\u3059\u308b\u4e3b\u306a\u60c5\u5831<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding: 8px;\"><strong>\u5165\u5ba4\u8a31\u53ef<\/strong><\/td>\n<td style=\"padding: 8px;\">\u300c\u3069\u306e<code>\u793e\u54e1ID<\/code>\u300d\u304c\u300c\u3069\u306e<code>\u5ba4ID<\/code>\u300d\u3078\u306e\u5165\u5ba4\u3092\u8a31\u53ef\u3055\u308c\u3066\u3044\u308b\u304b<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 8px;\"><strong>\u5165\u9000\u5ba4\u30ed\u30b0<\/strong><\/td>\n<td style=\"padding: 8px;\">\u300c\u3069\u306e<code>\u30ab\u30fc\u30c9ID<\/code>\u300d\u304c\u300c\u3069\u306e<code>\u5ba4ID<\/code>\u300d\u306b\u300c\u3044\u3064\u300d\u5165\u9000\u5ba4\u3057\u305f\u304b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u300c\u5165\u9000\u5ba4\u30ed\u30b0\u300d\u30c6\u30fc\u30d6\u30eb\u306f\u3001\u30ed\u30b0\u304c\u8a18\u9332\u3055\u308c\u305f\u6642\u70b9\u3067\u5fc5\u8981\u306a\u60c5\u5831\uff08\u30ab\u30fc\u30c9ID\u3001\u5ba4ID\u3001\u65e5\u6642\uff09\u304c\u3059\u3079\u3066\u63c3\u3063\u3066\u3044\u307e\u3059\u3002\u5f8c\u304b\u3089\u300c\u3053\u306e\u5165\u5ba4\u306f\u8a31\u53ef\u3055\u308c\u3066\u3044\u305f\u304b\uff1f\u300d\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u51e6\u7406\u306f\u767a\u751f\u3059\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u305d\u308c\u306f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5074\u306e\u30ed\u30b8\u30c3\u30af\u3067\u3059\u3002\u300c\u5165\u9000\u5ba4\u30ed\u30b0\u300d\u30c6\u30fc\u30d6\u30eb\u306e\u69cb\u9020\u3068\u3057\u3066\u3001\u300c\u5165\u5ba4\u8a31\u53ef\u300d\u30c6\u30fc\u30d6\u30eb\u306e\u60c5\u5831\u3092\u5916\u90e8\u30ad\u30fc\u3068\u3057\u3066\u4fdd\u6301\u3059\u308b\u5fc5\u8981\u306f\u306a\u3044\u306e\u3067\u3059\u3002<\/p>\n<p>\u3082\u3057\u7121\u7406\u306b\u4e21\u8005\u3092\u7d50\u3076\u3068\u3001\u8a31\u53ef\u60c5\u5831\u304c\u5909\u66f4\u3055\u308c\u305f\u969b\u306b\u30ed\u30b0\u3068\u306e\u6574\u5408\u6027\u304c\u53d6\u308c\u306a\u304f\u306a\u308b\u306a\u3069\u3001\u304b\u3048\u3063\u3066\u30c7\u30fc\u30bf\u69cb\u9020\u304c\u8907\u96d1\u5316\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u5fc5\u8981\u306a\u60c5\u5831\u304c\u4ed6\u306e\u30c6\u30fc\u30d6\u30eb\uff08\u4eca\u56de\u306f<code>\u30ab\u30fc\u30c9<\/code>\u3084<code>\u5ba4<\/code>\uff09\u7d4c\u7531\u3067\u9593\u63a5\u7684\u306b\u53d6\u5f97\u3067\u304d\u308b\u306a\u3089\u3001\u76f4\u63a5\u306e\u7dda\u306f\u5f15\u304b\u306a\u3044\u306e\u304c\u6b63\u898f\u5316\u306e\u539f\u5247\u3067\u3059\u3002<\/p>\n<h3>ER\u56f3\u306f\u300c\u51e6\u7406\u300d\u3067\u306f\u306a\u304f\u300c\u30c7\u30fc\u30bf\u306e\u69cb\u9020\u300d\u3092\u8868\u3059<\/h3>\n<p>\u3053\u306e\u554f\u984c\u306f\u3001\u79c1\u305f\u3061\u306bER\u56f3\u306e\u6839\u672c\u7684\u306a\u5f79\u5272\u3092\u518d\u8a8d\u8b58\u3055\u305b\u3066\u304f\u308c\u307e\u3059\u3002ER\u56f3\u306f\u300c\u30c7\u30fc\u30bf\u306e\u6d41\u308c\u300d\u3084\u300c\u30b7\u30b9\u30c6\u30e0\u306e\u51e6\u7406\uff08A\u306e\u5f8c\u306bB\u3092\u5b9f\u884c\u3059\u308b\uff09\u300d\u3092\u63cf\u304f\u30d5\u30ed\u30fc\u30c1\u30e3\u30fc\u30c8\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u3042\u304f\u307e\u3067<strong>\u30c7\u30fc\u30bf\u306e\u9759\u7684\u306a\u300c\u69cb\u9020\u300d\u3068\u300c\u95a2\u4fc2\u6027\u300d<\/strong>\u3092\u793a\u3059\u3001\u3044\u308f\u3070\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u4e16\u754c\u306e\u8a2d\u8a08\u56f3\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u5bb6\u306e\u5efa\u7bc9\u8a2d\u8a08\u56f3\u306f\u3001\u30ea\u30d3\u30f3\u30b0\u3068\u30ad\u30c3\u30c1\u30f3\u306e\u4f4d\u7f6e\u95a2\u4fc2\uff08\u69cb\u9020\uff09\u3092\u793a\u3057\u307e\u3059\u304c\u3001\u300c\u671d\u8d77\u304d\u305f\u3089\u307e\u305a\u30ea\u30d3\u30f3\u30b0\u306b\u884c\u304d\u3001\u6b21\u306b\u30ad\u30c3\u30c1\u30f3\u3067\u304a\u8336\u3092\u6df9\u308c\u308b\u300d\u3068\u3044\u3063\u305f\u4eba\u306e\u52d5\u304d\uff08\u51e6\u7406\uff09\u306f\u63cf\u304d\u307e\u305b\u3093\u3002ER\u56f3\u3082\u540c\u3058\u3067\u3059\u3002\u300c\u5165\u5ba4\u8a31\u53ef\u300d\u30c6\u30fc\u30d6\u30eb\u3068\u300c\u5165\u9000-\u5ba4\u30ed\u30b0\u300d\u30c6\u30fc\u30d6\u30eb\u304c\u76f4\u63a5\u7d50\u3070\u306a\u3044\u306e\u306f\u3001\u5bb6\u306e\u8a2d\u8a08\u56f3\u3067\u8a00\u3048\u3070\u3001\u30ea\u30d3\u30f3\u30b0\u3068\u5bdd\u5ba4\u306e\u9593\u306b\u76f4\u63a5\u306e\u30c9\u30a2\u304c\u306a\u3044\u3088\u3046\u306a\u3082\u306e\u3002\u5eca\u4e0b\uff08\u4ed6\u306e\u30c6\u30fc\u30d6\u30eb\uff09\u3092\u4ecb\u3057\u3066\u884c\u304d\u6765\u3067\u304d\u308b\u306a\u3089\u3001\u69cb\u9020\u3068\u3057\u3066\u76f4\u63a5\u7e4b\u3050\u5fc5\u8981\u306f\u306a\u3044\u3001\u3068\u3044\u3046\u8003\u3048\u65b9\u306a\u306e\u3067\u3059\u3002<\/p>\n<p>\u8a2d\u554f1\u306f\u3001\u3053\u306e\u300c\u69cb\u9020\u3068\u51e6\u7406\u306e\u5206\u96e2\u300d\u3068\u3044\u3046\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u8a2d\u8a08\u306e\u57fa\u672c\u539f\u5247\u3092\u7406\u89e3\u3057\u3066\u3044\u308b\u304b\u3092\u554f\u3046\u3001\u975e\u5e38\u306b\u512a\u308c\u305f\u554f\u984c\u3060\u3063\u305f\u3068\u8a00\u3048\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n<h2>\u8a2d\u554f\u2461\u3067\u5b66\u3076\u8907\u5408\u4e3b\u30ad\u30fc\uff1a\u306a\u305c\u300c\u793e\u54e1ID\uff0b\u5ba4ID\u300d\u3067\u4e00\u610f\u6027\u3092\u62c5\u4fdd\u3059\u308b\u306e\u304b<\/h2>\n<p>\u8a2d\u554f\u2461\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u8a2d\u8a08\u306e\u6838\u5fc3\u3068\u3082\u8a00\u3048\u308b\u300c\u4e3b\u30ad\u30fc\u300d\u306e\u6982\u5ff5\u3001\u7279\u306b\u8907\u6570\u306e\u5217\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u300c\u8907\u5408\u4e3b\u30ad\u30fc\u300d\u306e\u5fc5\u8981\u6027\u3092\u554f\u3046\u554f\u984c\u3067\u3059\u3002\u306a\u305c\u300c\u5165\u5ba4\u8a31\u53ef\u300d\u30c6\u30fc\u30d6\u30eb\u3067\u306f\u3001\u5358\u4e00\u306eID\u3067\u306f\u306a\u304f\u300c\u793e\u54e1ID\u300d\u3068\u300c\u5ba4ID\u300d\u306e2\u3064\u3092\u30bb\u30c3\u30c8\u3067\u4e3b\u30ad\u30fc\u306b\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u306e\u3067\u3057\u3087\u3046\u304b\u3002\u305d\u306e\u7b54\u3048\u306f\u3001\u300c\u793e\u54e1\u300d\u3068\u300c\u5ba4\u300d\u306e\u9593\u306b\u5b58\u5728\u3059\u308b\u201c\u591a\u5bfe\u591a\u201d\u306e\u95a2\u4fc2\u6027\u306b\u3042\u308a\u307e\u3059\u3002<\/p>\n<h3>\u300c\u5165\u5ba4\u8a31\u53ef\u300d\u306f\u201c\u591a\u5bfe\u591a\u201d\u3092\u89e3\u6c7a\u3059\u308b\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb<\/h3>\n<p>\u307e\u305a\u3001\u300c\u793e\u54e1\u300d\u3068\u300c\u5ba4\u300d\u306e\u95a2\u4fc2\u6027\u3092\u6574\u7406\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<ul>\n<li>\u4e00\u4eba\u306e\u793e\u54e1\u306f\u3001\u8907\u6570\u306e\u5ba4\u3078\u306e\u5165\u5ba4\u3092\u8a31\u53ef\u3055\u308c\u308b\u3053\u3068\u304c\u3042\u308b\u3002\uff08\u4f8b\uff1aA\u3055\u3093\u306f\u30b5\u30fc\u30d0\u5ba4\u3068\u8cc7\u6599\u5ba4\u306b\u5165\u308c\u308b\uff09<\/li>\n<li>\u4e00\u3064\u306e\u5ba4\u306f\u3001\u8907\u6570\u306e\u793e\u54e1\u306b\u5165\u5ba4\u304c\u8a31\u53ef\u3055\u308c\u3066\u3044\u308b\u3002\uff08\u4f8b\uff1a\u30b5\u30fc\u30d0\u5ba4\u306b\u306fA\u3055\u3093\u3001B\u3055\u3093\u3001C\u3055\u3093\u304c\u5165\u308c\u308b\uff09<\/li>\n<\/ul>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u4e92\u3044\u306b\u300c\u591a\u300d\u306e\u95a2\u4fc2\u306b\u3042\u308b\u72b6\u614b\u3092<strong>\u300c\u591a\u5bfe\u591a\uff08many-to-many\uff09\u300d<\/strong>\u3068\u547c\u3073\u307e\u3059\u3002\u30ea\u30ec\u30fc\u30b7\u30e7\u30ca\u30eb\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u306f\u3001\u3053\u306e\u591a\u5bfe\u591a\u306e\u95a2\u4fc2\u3092\u76f4\u63a5\u8868\u73fe\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002\u305d\u3053\u3067\u767b\u5834\u3059\u308b\u306e\u304c\u3001\u4e21\u8005\u306e\u9593\u306b\u631f\u307e\u308b<strong>\u300c\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\uff08\u9023\u95a2\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\uff09\u300d<\/strong>\u3067\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306e\u300c\u5165\u5ba4\u8a31\u53ef\u300d\u30c6\u30fc\u30d6\u30eb\u306f\u3001\u307e\u3055\u306b\u3053\u306e\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\u306e\u5f79\u5272\u3092\u62c5\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre style=\"background-color: #f9f9f9; padding: 15px; border: 1px solid #ddd;\">\n\u3010\u793e\u54e1\u30c6\u30fc\u30d6\u30eb\u3011 ----&gt; (1\u5bfe\u591a) ----&gt; \u3010\u5165\u5ba4\u8a31\u53ef\u30c6\u30fc\u30d6\u30eb\u3011\n\u3010\u5ba4\u30c6\u30fc\u30d6\u30eb\u3011   ----&gt; (1\u5bfe\u591a) ----&gt; \u3010\u5165\u5ba4\u8a31\u53ef\u30c6\u30fc\u30d6\u30eb\u3011\n<\/pre>\n<p>\u4e0a\u56f3\u306e\u3088\u3046\u306b\u3001\u300c\u793e\u54e1\u300d\u3068\u300c\u5165\u5ba4\u8a31\u53ef\u300d\u306f1\u5bfe\u591a\u3001\u300c\u5ba4\u300d\u3068\u300c\u5165\u5ba4\u8a31\u53ef\u300d\u30821\u5bfe\u591a\u3067\u3059\u3002\u3053\u306e\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\u3092\u8a2d\u3051\u308b\u3053\u3068\u3067\u3001\u8907\u96d1\u306a\u591a\u5bfe\u591a\u306e\u95a2\u4fc2\u3092\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304c\u6271\u3048\u308b\u30b7\u30f3\u30d7\u30eb\u306a\u300c1\u5bfe\u591a\u300d\u306e\u7d44\u307f\u5408\u308f\u305b\u306b\u5206\u89e3\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u3002<\/p>\n<h3>\u5358\u4e00\u30ad\u30fc\u3067\u306f\u696d\u52d9\u8981\u4ef6\u3092\u8868\u73fe\u3067\u304d\u306a\u3044<\/h3>\n<p>\u3067\u306f\u3001\u306a\u305c\u300c\u5165\u5ba4\u8a31\u53ef\u300d\u30c6\u30fc\u30d6\u30eb\u306e\u4e3b\u30ad\u30fc\u306f\u4e00\u3064\u3067\u306f\u30c0\u30e1\u306a\u306e\u3067\u3057\u3087\u3046\u304b\u3002\u5177\u4f53\u7684\u306b\u8003\u3048\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<ul>\n<li><strong>\u3082\u3057\u300c\u793e\u54e1ID\u300d\u3060\u3051\u3092\u4e3b\u30ad\u30fc\u306b\u3057\u305f\u3089\uff1f<\/strong><br \/>\u4e3b\u30ad\u30fc\u306f\u91cd\u8907\u304c\u8a31\u3055\u308c\u306a\u3044\u305f\u3081\u3001\u300c\u793e\u54e1ID &#8216;E001&#8217;\u300d\u306e\u884c\u306f1\u884c\u3057\u304b\u4f5c\u308c\u307e\u305b\u3093\u3002\u3064\u307e\u308a\u3001\u793e\u54e1E001\u3055\u3093\u306f\u3001\u3069\u308c\u304b1\u3064\u306e\u5ba4\u306e\u8a31\u53ef\u3057\u304b\u767b\u9332\u3067\u304d\u305a\u3001\u8907\u6570\u306e\u5ba4\u3078\u306e\u5165\u5ba4\u8a31\u53ef\u3092\u4e0e\u3048\u3089\u308c\u306a\u304f\u306a\u308a\u307e\u3059\u3002<\/li>\n<li><strong>\u3082\u3057\u300c\u5ba4ID\u300d\u3060\u3051\u3092\u4e3b\u30ad\u30fc\u306b\u3057\u305f\u3089\uff1f<\/strong><br \/>\u540c\u69d8\u306b\u3001\u300c\u5ba4ID &#8216;S101&#8217;\u300d\u306e\u884c\u304c1\u884c\u3057\u304b\u4f5c\u308c\u307e\u305b\u3093\u3002\u3064\u307e\u308a\u3001S101\u5ba4\u306b\u306f\u3001\u8ab0\u304b1\u4eba\u306e\u793e\u54e1\u3057\u304b\u5165\u5ba4\u8a31\u53ef\u3092\u4e0e\u3048\u3089\u308c\u306a\u304f\u306a\u308a\u307e\u3059\u3002<\/li>\n<\/ul>\n<p>\u3069\u3061\u3089\u306e\u30b1\u30fc\u30b9\u3082\u3001\u5b9f\u969b\u306e\u696d\u52d9\u8981\u4ef6\uff08\u300c\u4e00\u4eba\u306e\u793e\u54e1\u304c\u8907\u6570\u62e0\u70b9\u306b\u5165\u308c\u308b\u300d\u300c\u4e00\u3064\u306e\u62e0\u70b9\u306b\u8907\u6570\u304c\u6240\u5c5e\u3059\u308b\u300d\u306a\u3069\uff09\u3092\u6e80\u305f\u305b\u307e\u305b\u3093\u3002<\/p>\n<h3>\u300c\u793e\u54e1ID\uff0b\u5ba4ID\u300d\u306e\u7d44\u307f\u5408\u308f\u305b\u3067\u521d\u3081\u3066\u4e00\u610f\u306b\u306a\u308b<\/h3>\n<p>\u305d\u3053\u3067\u8907\u5408\u4e3b\u30ad\u30fc\u306e\u51fa\u756a\u3067\u3059\u3002\u8907\u5408\u4e3b\u30ad\u30fc\u3068\u306f\u3001<strong>\u8907\u6570\u306e\u5217\u3092\u4e00\u3064\u306e\u30bb\u30c3\u30c8\u3068\u3057\u3066\u6271\u3044\u3001\u305d\u306e\u300c\u7d44\u307f\u5408\u308f\u305b\u300d\u306e\u91cd\u8907\u3092\u8a31\u3055\u306a\u3044<\/strong>\u3068\u3044\u3046\u5236\u7d04\u3067\u3059\u3002<\/p>\n<p>\u300c\u5165\u5ba4\u8a31\u53ef\u300d\u30c6\u30fc\u30d6\u30eb\u3067\u306f\u3001\u300c\u3069\u306e\u793e\u54e1\u304c\u3001\u3069\u306e\u5ba4\u3078\u306e\u5165\u5ba4\u3092\u8a31\u53ef\u3055\u308c\u3066\u3044\u308b\u304b\u300d\u3068\u3044\u3046\u60c5\u5831\u305d\u306e\u3082\u306e\u304c1\u3064\u306e\u30ec\u30b3\u30fc\u30c9\u306e\u610f\u5473\u3092\u6301\u3061\u307e\u3059\u3002<\/p>\n<table border=\"1\" style=\"width:100%; border-collapse: collapse;\">\n<thead>\n<tr>\n<th style=\"padding: 8px; background-color: #f2f2f2;\">\u793e\u54e1ID\uff08\u4e3b\u30ad\u30fc\u306e\u4e00\u90e8\uff09<\/th>\n<th style=\"padding: 8px; background-color: #f2f2f2;\">\u5ba4ID\uff08\u4e3b\u30ad\u30fc\u306e\u4e00\u90e8\uff09<\/th>\n<th style=\"padding: 8px; background-color: #f2f2f2;\">\u8a31\u53ef\u65e5\u6642<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding: 8px;\">E001<\/td>\n<td style=\"padding: 8px;\">S101<\/td>\n<td style=\"padding: 8px;\">2025-10-01<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 8px;\">E001<\/td>\n<td style=\"padding: 8px;\">S205<\/td>\n<td style=\"padding: 8px;\">2025-10-01<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 8px;\">E002<\/td>\n<td style=\"padding: 8px;\">S101<\/td>\n<td style=\"padding: 8px;\">2025-10-02<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u3053\u306e\u8868\u3067\u306f\u3001<\/p>\n<ul>\n<li><code>E001<\/code> \u3068\u3044\u3046\u793e\u54e1ID\u306f\u8907\u6570\u56de\u767b\u5834\u3067\u304d\u307e\u3059\u3002<\/li>\n<li><code>S101<\/code> \u3068\u3044\u3046\u5ba4ID\u3082\u8907\u6570\u56de\u767b\u5834\u3067\u304d\u307e\u3059\u3002<\/li>\n<li>\u3057\u304b\u3057\u3001<strong><code>(E001, S101)<\/code> \u3068\u3044\u3046\u7d44\u307f\u5408\u308f\u305b\u306f\u3001\u3053\u306e\u30c6\u30fc\u30d6\u30eb\u5185\u3067\u4e00\u5ea6\u3057\u304b\u767b\u5834\u3067\u304d\u307e\u305b\u3093\u3002<\/strong><\/li>\n<\/ul>\n<p>\u3053\u308c\u306b\u3088\u308a\u3001\u300c\u4e00\u4eba\u306e\u793e\u54e1\u304c\u8907\u6570\u306e\u5ba4\u306e\u6a29\u9650\u3092\u6301\u3064\u300d\u300c\u4e00\u3064\u306e\u5ba4\u306b\u8907\u6570\u306e\u793e\u54e1\u304c\u6a29\u9650\u3092\u6301\u3064\u300d\u3068\u3044\u3046\u591a\u5bfe\u591a\u306e\u95a2\u4fc2\u3092\u3001\u30c7\u30fc\u30bf\u306e\u6574\u5408\u6027\u3092\u4fdd\u3061\u306a\u304c\u3089\u5b8c\u74a7\u306b\u8868\u73fe\u3067\u304d\u308b\u306e\u3067\u3059\u3002SQL\u3067\u30c6\u30fc\u30d6\u30eb\u3092\u5b9a\u7fa9\u3059\u308b\u969b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<pre><code>CREATE TABLE \u5165\u5ba4\u8a31\u53ef (\n    \u793e\u54e1ID VARCHAR(10),\n    \u5ba4ID VARCHAR(10),\n    \u8a31\u53ef\u65e5\u6642 DATE,\n    ...,\n    PRIMARY KEY (\u793e\u54e1ID, \u5ba4ID) -- \u3053\u3053\u3067\u8907\u5408\u4e3b\u30ad\u30fc\u3092\u5b9a\u7fa9\n);\n<\/code><\/pre>\n<h3>\u8907\u5408\u30ad\u30fc\u306f\u300c\u6b63\u898f\u5316\u300d\u306e\u81ea\u7136\u306a\u7d50\u679c<\/h3>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u8a2d\u8a08\u306b\u306f\u300c\u6b63\u898f\u5316\u300d\u3068\u3044\u3046\u3001\u30c7\u30fc\u30bf\u306e\u91cd\u8907\u3092\u306a\u304f\u3057\u3001\u6574\u5408\u6027\u3092\u9ad8\u3081\u308b\u305f\u3081\u306e\u91cd\u8981\u306a\u30d7\u30ed\u30bb\u30b9\u304c\u3042\u308a\u307e\u3059\u3002\u8a73\u7d30\u306f\u5272\u611b\u3057\u307e\u3059\u304c\u3001\u3053\u306e\u6b63\u898f\u5316\u3092\u9032\u3081\u308b\u904e\u7a0b\u3067\u591a\u5bfe\u591a\u306e\u95a2\u4fc2\u304c\u898b\u3064\u304b\u308b\u3068\u3001\u305d\u308c\u3092\u89e3\u6d88\u3059\u308b\u305f\u3081\u306b\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\u304c\u4f5c\u3089\u308c\u307e\u3059\u3002\u305d\u3057\u3066\u3001\u305d\u306e\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\u306e\u4e3b\u30ad\u30fc\u306f\u3001\u5143\u3068\u306a\u3063\u305f2\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u4e3b\u30ad\u30fc\u3092\u5f15\u304d\u7d99\u3044\u3060\u8907\u5408\u4e3b\u30ad\u30fc\u3068\u306a\u308b\u306e\u304c\u6700\u3082\u81ea\u7136\u306a\u5f62\u306a\u306e\u3067\u3059\u3002<\/p>\n<p>\u3053\u308c\u306f\u5b9f\u4e16\u754c\u306e\u696d\u52d9\u3067\u3082\u983b\u7e41\u306b\u73fe\u308c\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u300c\u9867\u5ba2\u300d\u3068\u300c\u5546\u54c1\u300d\u306e\u95a2\u4fc2\u3092\u7ba1\u7406\u3059\u308bEC\u30b5\u30a4\u30c8\u306e\u300c\u8cfc\u5165\u5c65\u6b74\u300d\u30c6\u30fc\u30d6\u30eb\u306f\u3001\u3069\u306e\u9867\u5ba2\u304c\u3069\u306e\u5546\u54c1\u3092\u8cb7\u3063\u305f\u304b\u306e\u8a18\u9332\u3067\u3042\u308a\u3001\u901a\u5e38\u306f\u300c\u9867\u5ba2ID\u300d\u3068\u300c\u5546\u54c1ID\u300d\u306e\u8907\u5408\u4e3b\u30ad\u30fc\uff08\u5834\u5408\u306b\u3088\u3063\u3066\u306f\u8cfc\u5165\u65e5\u6642\u3082\u542b\u3080\uff09\u3092\u6301\u3061\u307e\u3059\u3002\u8a2d\u554f\u2461\u306f\u3001\u3053\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u8a2d\u8a08\u306e\u5b9a\u77f3\u3092\u7406\u89e3\u3057\u3066\u3044\u308b\u304b\u3092\u554f\u3046\u554f\u984c\u3060\u3063\u305f\u306e\u3067\u3059\u3002<\/p>\n<h2>ER\u56f3\u306e\u8aad\u89e3\u3092\u6df1\u3081\u308b\uff1a\u30ab\u30fc\u30c7\u30a3\u30ca\u30ea\u30c6\u30a3\uff08\u591a\u91cd\u5ea6\uff09\u3068\u30c6\u30fc\u30d6\u30eb\u306e\u4f9d\u5b58\u95a2\u4fc2<\/h2>\n<p>ER\u56f3\u3092\u3055\u3089\u306b\u6df1\u304f\u8aad\u307f\u89e3\u304f\u305f\u3081\u306b\u306f\u3001\u300c\u30ab\u30fc\u30c7\u30a3\u30ca\u30ea\u30c6\u30a3\u300d\u3068\u300c\u4f9d\u5b58\u95a2\u4fc2\u300d\u3068\u3044\u30462\u3064\u306e\u6982\u5ff5\u3092\u7406\u89e3\u3059\u308b\u3053\u3068\u304c\u4e0d\u53ef\u6b20\u3067\u3059\u3002\u30ab\u30fc\u30c7\u30a3\u30ca\u30ea\u30c6\u30a3\uff08\u591a\u91cd\u5ea6\uff09\u3068\u306f\u3001\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u9593\u306e\u95a2\u4fc2\u304c\u300c1\u5bfe1\u300d\u306a\u306e\u304b\u3001\u300c1\u5bfe\u591a\u300d\u306a\u306e\u304b\u3001\u300c\u591a\u5bfe\u591a\u300d\u306a\u306e\u304b\u3092\u793a\u3059\u6570\u306e\u5bfe\u5fdc\u95a2\u4fc2\u3092\u6307\u3057\u307e\u3059\u3002\u305d\u3057\u3066\u3001\u3053\u306e\u95a2\u4fc2\u6027\u306f\u30c6\u30fc\u30d6\u30eb\u9593\u306e\u300c\u4f9d\u5b58\u95a2\u4fc2\u300d\u306b\u3088\u3063\u3066\u6210\u308a\u7acb\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>\u300c1\u5bfe\u591a\u300d\u306f\u201c\u591a\u201d\u5074\u304c\u201c1\u201d\u5074\u3092\u53c2\u7167\u3057\u3066\u6210\u308a\u7acb\u3064<\/h3>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u304a\u3051\u308b\u30c6\u30fc\u30d6\u30eb\u9593\u306e\u95a2\u4fc2\u3067\u6700\u3082\u4e00\u822c\u7684\u306a\u306e\u304c\u300c1\u5bfe\u591a\u300d\u3067\u3059\u3002\u3053\u306e\u95a2\u4fc2\u306f\u3001\u3069\u306e\u3088\u3046\u306b\u3057\u3066\u6210\u7acb\u3059\u308b\u306e\u3067\u3057\u3087\u3046\u304b\u3002\u305d\u308c\u306f\u3001<strong>\u300c\u591a (N)\u300d\u5074\u306e\u30c6\u30fc\u30d6\u30eb\u304c\u3001\u300c1\u300d\u5074\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u4e3b\u30ad\u30fc\u3092\u5916\u90e8\u30ad\u30fc\u3068\u3057\u3066\u6301\u3064<\/strong>\u3068\u3044\u3046\u69cb\u9020\u7684\u306a\u30eb\u30fc\u30eb\u306b\u57fa\u3065\u3044\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306e\u554f\u984c\u306b\u304a\u3051\u308b\u300c\u793e\u54e1\u300d\u3068\u300c\u30ab\u30fc\u30c9\u300d\u306e\u95a2\u4fc2\u304c\u5178\u578b\u4f8b\u3067\u3059\u3002<\/p>\n<ul>\n<li>1\u4eba\u306e\u793e\u54e1\u306f\u3001\u8907\u6570\u306e\u30ab\u30fc\u30c9\u3092\u6240\u6301\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\uff08\u7d1b\u5931\u30fb\u518d\u767a\u884c\u306a\u3069\uff09\u3002<\/li>\n<li>1\u679a\u306e\u30ab\u30fc\u30c9\u306f\u3001\u7279\u5b9a\u306e1\u4eba\u306e\u793e\u54e1\u306b\u3057\u304b\u7d10\u3065\u304b\u306a\u3044\u3002<\/li>\n<\/ul>\n<p>\u3053\u306e\u696d\u52d9\u30eb\u30fc\u30eb\u3092\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u5b9f\u73fe\u3059\u308b\u305f\u3081\u306b\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8a2d\u8a08\u304c\u884c\u308f\u308c\u307e\u3059\u3002<\/p>\n<pre style=\"background-color: #f9f9f9; padding: 15px; border: 1px solid #ddd;\">\n\u3010\u793e\u54e1\u30c6\u30fc\u30d6\u30eb\u3011 (1\u5074)\n  <strong>\u793e\u54e1ID (\u4e3b\u30ad\u30fc)<\/strong>\n  \u6c0f\u540d\n  ...\n\n\u3010\u30ab\u30fc\u30c9\u30c6\u30fc\u30d6\u30eb\u3011 (\u591a\u5074)\n  \u30ab\u30fc\u30c9ID (\u4e3b\u30ad\u30fc)\n  <strong>\u793e\u54e1ID (\u5916\u90e8\u30ad\u30fc)<\/strong>  &lt;-- \u3053\u3053\u3067\u793e\u54e1\u30c6\u30fc\u30d6\u30eb\u3092\u53c2\u7167\n  \u767a\u884c\u65e5\n  ...\n<\/pre>\n<p>\u300c\u30ab\u30fc\u30c9\u300d\u30c6\u30fc\u30d6\u30eb\u304c\u5916\u90e8\u30ad\u30fc\u3068\u3057\u3066\u300c\u793e\u54e1ID\u300d\u3092\u6301\u3064\u3053\u3068\u3067\u3001\u300c\u3053\u306e\u30ab\u30fc\u30c9\u306f\u3001\u3069\u306e\u793e\u54e1\u306e\u3082\u306e\u304b\u300d\u3068\u3044\u3046\u60c5\u5831\u304c\u660e\u78ba\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u300c\u793e\u54e1\u300d\u3092\u89aa\u3001\u300c\u30ab\u30fc\u30c9\u300d\u3092\u5b50\u3068\u3059\u308b\u89aa\u5b50\u306e\u3088\u3046\u306a\u95a2\u4fc2\u3001\u3059\u306a\u308f\u3061<strong>\u4f9d\u5b58\u95a2\u4fc2<\/strong>\u304c\u751f\u307e\u308c\u308b\u306e\u3067\u3059\u3002<\/p>\n<h3>\u4f9d\u5b58\u95a2\u4fc2\u304c\u306a\u3051\u308c\u3070\u30ab\u30fc\u30c7\u30a3\u30ca\u30ea\u30c6\u30a3\u306f\u5b58\u5728\u3057\u306a\u3044<\/h3>\n<p>\u524d\u8ff0\u306e\u300c\u4f9d\u5b58\u95a2\u4fc2\u300d\u3068\u306f\u3001\u3088\u308a\u53b3\u5bc6\u306b\u8a00\u3046\u3068<strong>\u300c\u5b50\u30c6\u30fc\u30d6\u30eb\u306e\u30ec\u30b3\u30fc\u30c9\u306f\u3001\u89aa\u30c6\u30fc\u30d6\u30eb\u306b\u5bfe\u5fdc\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u304c\u5b58\u5728\u3057\u306a\u3044\u9650\u308a\u3001\u5b58\u5728\u3067\u304d\u306a\u3044\u300d<\/strong>\u3068\u3044\u3046\u5236\u7d04\uff08\u53c2\u7167\u6574\u5408\u6027\u5236\u7d04\uff09\u3092\u610f\u5473\u3057\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u307e\u3060\u300c\u793e\u54e1\u300d\u30c6\u30fc\u30d6\u30eb\u306b\u767b\u9332\u3055\u308c\u3066\u3044\u306a\u3044\u300c\u793e\u54e1ID: E999\u300d\u3092\u6301\u3064\u30ab\u30fc\u30c9\u60c5\u5831\u3092\u3001\u300c\u30ab\u30fc\u30c9\u300d\u30c6\u30fc\u30d6\u30eb\u306b\u3044\u304d\u306a\u308a\u767b\u9332\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306f\u300c\u53c2\u7167\u5148\u304c\u5b58\u5728\u3057\u307e\u305b\u3093\u300d\u3068\u3044\u3046\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002\u3053\u308c\u304c\u4f9d\u5b58\u95a2\u4fc2\u3067\u3059\u3002\u30ab\u30fc\u30c9\u306f\u3001\u793e\u54e1\u3068\u3044\u3046\u5b58\u5728\u306b\u4f9d\u5b58\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u95a2\u4fc2\u306f\u3001EC\u30b5\u30a4\u30c8\u306b\u304a\u3051\u308b\u300c\u6ce8\u6587\u300d\u3068\u300c\u6ce8\u6587\u660e\u7d30\u300d\u306e\u95a2\u4fc2\u306b\u4f3c\u3066\u3044\u307e\u3059\u3002<\/p>\n<ul>\n<li><strong>\u6ce8\u6587<\/strong>\uff1a\u300c2025\u5e7410\u67087\u65e5\u306e\u7530\u4e2d\u69d8\u306e\u8cfc\u5165\u300d\u3068\u3044\u3046\u53d6\u5f15\u5168\u4f53\u3002<\/li>\n<li><strong>\u6ce8\u6587\u660e\u7d30<\/strong>\uff1a\u300c\u308a\u3093\u30542\u500b\u300d\u300c\u307f\u304b\u30933\u500b\u300d\u3068\u3044\u3063\u305f\u53d6\u5f15\u306e\u5404\u54c1\u76ee\u3002<\/li>\n<\/ul>\n<p>\u300c\u3069\u306e\u6ce8\u6587\u306b\u3082\u5c5e\u3055\u306a\u3044\u3001\u8b0e\u306e\u6ce8\u6587\u660e\u7d30\u300d\u304c\u5b58\u5728\u3057\u5f97\u306a\u3044\u3088\u3046\u306b\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u4e16\u754c\u3067\u3082\u300c\u3069\u306e\u793e\u54e1\u306b\u3082\u7d10\u3065\u304b\u306a\u3044\u3001\u8b0e\u306e\u30ab\u30fc\u30c9\u300d\u306f\u5b58\u5728\u3067\u304d\u307e\u305b\u3093\u3002ER\u56f3\u306b\u63cf\u304b\u308c\u308b\u7dda\uff08\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u30b7\u30c3\u30d7\uff09\u306f\u3001\u5358\u306a\u308b\u95a2\u9023\u6027\u3067\u306f\u306a\u304f\u3001\u3053\u306e\u3088\u3046\u306a\u30c7\u30fc\u30bf\u306e\u5b58\u5728\u3092\u304b\u3051\u305f\u5f37\u3044\u4f9d\u5b58\u95a2\u4fc2\u3092\u8868\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u3002<\/p>\n<h3>\u8907\u5408\u30ad\u30fc\u3092\u6301\u3064\u30c6\u30fc\u30d6\u30eb\u306f\u201c\u4e21\u89aa\u201d\u306b\u4f9d\u5b58\u3059\u308b<\/h3>\n<p>\u3067\u306f\u3001\u8a2d\u554f\u2461\u3067\u767b\u5834\u3057\u305f\u300c\u5165\u5ba4\u8a31\u53ef\u300d\u30c6\u30fc\u30d6\u30eb\u306f\u3069\u3046\u3067\u3057\u3087\u3046\u304b\u3002\u3053\u306e\u30c6\u30fc\u30d6\u30eb\u306f\u300c\u793e\u54e1ID\u300d\u3068\u300c\u5ba4ID\u300d\u306e\u8907\u5408\u4e3b\u30ad\u30fc\u3092\u6301\u3063\u3066\u3044\u307e\u3057\u305f\u3002\u3053\u308c\u306f\u30012\u3064\u306e\u5916\u90e8\u30ad\u30fc\u3092\u4f75\u305b\u6301\u3064\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\u3002<\/p>\n<pre style=\"background-color: #f9f9f9; padding: 15px; border: 1px solid #ddd;\">\n\u3010\u793e\u54e1\u30c6\u30fc\u30d6\u30eb\u3011 ----&gt; \u53c2\u7167\u3055\u308c\u308b ----&gt; \u3010\u5165\u5ba4\u8a31\u53ef\u30c6\u30fc\u30d6\u30eb\u3011\n\u3010\u5ba4\u30c6\u30fc\u30d6\u30eb\u3011   ----&gt; \u53c2\u7167\u3055\u308c\u308b ----&gt; \u3010\u5165\u5ba4\u8a31\u53ef\u30c6\u30fc\u30d6\u30eb\u3011\n<\/pre>\n<p>\u3053\u306e\u69cb\u9020\u304c\u793a\u3059\u306e\u306f\u3001\u300c\u5165\u5ba4\u8a31\u53ef\u300d\u30c6\u30fc\u30d6\u30eb\u304c<strong>2\u3064\u306e\u89aa\u30c6\u30fc\u30d6\u30eb\uff08\u793e\u54e1\u3001\u5ba4\uff09\u306b\u540c\u6642\u306b\u4f9d\u5b58\u3057\u3066\u3044\u308b<\/strong>\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u300c\u5165\u5ba4\u8a31\u53ef\u300d\u30ec\u30b3\u30fc\u30c9\u306e<code>\u793e\u54e1ID<\/code>\u306f\u3001\u300c\u793e\u54e1\u300d\u30c6\u30fc\u30d6\u30eb\u306b\u5b9f\u5728\u3059\u308bID\u3067\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002<\/li>\n<li>\u300c\u5165\u5ba4\u8a31\u53ef\u300d\u30ec\u30b3\u30fc\u30c9\u306e<code>\u5ba4ID<\/code>\u306f\u3001\u300c\u5ba4\u300d\u30c6\u30fc\u30d6\u30eb\u306b\u5b9f\u5728\u3059\u308bID\u3067\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002<\/li>\n<\/ul>\n<p>\u3064\u307e\u308a\u3001\u300c\u5b58\u5728\u3057\u306a\u3044\u793e\u54e1\u300d\u3084\u300c\u5b58\u5728\u3057\u306a\u3044\u5ba4\u300d\u306b\u5bfe\u3059\u308b\u5165\u5ba4\u8a31\u53ef\u60c5\u5831\u306f\u3001\u7d76\u5bfe\u306b\u767b\u9332\u3067\u304d\u306a\u3044\u4ed5\u7d44\u307f\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\u306f\u3001\u3053\u306e\u3088\u3046\u306b\u8907\u6570\u306e\u89aa\u30c6\u30fc\u30d6\u30eb\u306e\u201c\u8eab\u5143\u201d\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u5168\u4f53\u306e\u6574\u5408\u6027\u3092\u4fdd\u3064\u30cf\u30d6\u306e\u5f79\u5272\u3092\u679c\u305f\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u3002\u3053\u306e\u300c\u591a\u65b9\u9762\u3078\u306e\u4f9d\u5b58\u300d\u3092\u7406\u89e3\u3059\u308b\u3053\u3068\u304c\u3001\u8907\u96d1\u306a\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u69cb\u9020\u3092\u6b63\u78ba\u306b\u628a\u63e1\u3059\u308b\u9375\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>\u8a2d\u554f\u2462SQL\u30c8\u30ea\u30c3\u30af\u89e3\u8aac\uff1aINNER JOIN\u3068COUNT(*)\u3067\u300c\u5b58\u5728\u78ba\u8a8d\u300d\u3059\u308b\u8ad6\u7406<\/h2>\n<p>\u8a2d\u554f\u2462\u306f\u3001\u672c\u8a66\u9a13\u306e\u6838\u5fc3\u3068\u3082\u8a00\u3048\u308b\u8907\u96d1\u306aSQL\u8aad\u89e3\u554f\u984c\u3067\u3059\u3002\u63d0\u793a\u3055\u308c\u305fSELECT\u6587\u304c\u3001\u3069\u306e\u3088\u3046\u306b\u3057\u3066\u300c\u5165\u5ba4\u8a31\u53ef\u306e\u3042\u308b\u793e\u54e1\u30fb\u5ba4\u306e\u7d44\u307f\u5408\u308f\u305b\u306b\u5bfe\u3057\u3001\u5165\u5ba4\u5b9f\u7e3e\u304c\u3042\u308c\u3070\u300e1\u300f\u3092\u3001\u306a\u3051\u308c\u3070\u305d\u306e\u884c\u81ea\u4f53\u3092\u8fd4\u3055\u306a\u3044\u300d\u3068\u3044\u3046\u51e6\u7406\u3092\u5b9f\u73fe\u3057\u3066\u3044\u308b\u306e\u304b\u3002\u305d\u306e\u9375\u306f<code>INNER JOIN<\/code>\u3001<code>GROUP BY<\/code>\u3001<code>COUNT(*)<\/code>\u3001\u305d\u3057\u3066<code>HAVING<\/code>\u53e5\u306e\u9023\u643a\u306b\u3042\u308a\u307e\u3059\u3002\u3053\u306eSQL\u306e\u52d5\u4f5c\u3092\u4e00\u3064\u305a\u3064\u5206\u89e3\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h3>\u76ee\u7684\uff1a\u300c\u793e\u54e1\u00d7\u5ba4\u300d\u306e\u7d44\u307f\u5408\u308f\u305b\u3054\u3068\u306b\u5165\u5ba4\u5b9f\u7e3e\u304c\u3042\u308b\u304b\u3092\u78ba\u8a8d\u3059\u308b<\/h3>\n<p>\u307e\u305a\u3001\u3053\u306eSQL\u304c\u9054\u6210\u3057\u305f\u3044\u76ee\u7684\u3092\u660e\u78ba\u306b\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002\u76ee\u7684\u306f\u975e\u5e38\u306b\u30b7\u30f3\u30d7\u30eb\u3067\u3059\u3002<br \/><strong>\u300c\u300e\u5165\u5ba4\u8a31\u53ef\u300f\u30c6\u30fc\u30d6\u30eb\u306b\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u3059\u3079\u3066\u306e\u6a29\u9650\uff08\u793e\u54e1ID\u3068\u5ba4ID\u306e\u30da\u30a2\uff09\u306b\u3064\u3044\u3066\u3001\u305d\u308c\u306b\u5bfe\u5fdc\u3059\u308b\u300e\u5165\u9000\u5ba4\u30ed\u30b0\u300f\u304c\u904e\u53bb\u306b1\u4ef6\u3067\u3082\u3042\u308b\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\u3057\u305f\u3044\u300d<\/strong><br \/>\u3068\u3044\u3046\u3082\u306e\u3067\u3059\u3002\u6700\u7d42\u7684\u306b\u6b32\u3057\u3044\u306e\u306f\u3001\u300c\u5b9f\u7e3e\u306e\u3042\u3063\u305f\u6a29\u9650\u30ea\u30b9\u30c8\u300d\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3>SQL\u69cb\u6587\u306e\u5206\u89e3\uff08\u554f\u984c\u306e\u518d\u73fe\uff09<\/h3>\n<p>\u554f\u984c\u3067\u554f\u308f\u308c\u3066\u3044\u308bSQL\u306e\u9aa8\u5b50\u3092\u518d\u73fe\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code>SELECT\n    T1.\u793e\u54e1ID,\n    T1.\u5ba4ID,\n    COUNT(*) AS \u5b9f\u7e3e     -- \u2462 \u30b0\u30eb\u30fc\u30d7\u3054\u3068\u306e\u4ef6\u6570\u3092\u6570\u3048\u3001\u300c\u5b9f\u7e3e\u300d\u3068\u3059\u308b\nFROM\n    \u5165\u5ba4\u8a31\u53ef AS T1\nINNER JOIN\n    \u5165\u9000\u5ba4\u30ed\u30b0 AS T2 ON ... -- \u2460 \u8a31\u53ef\u3068\u30ed\u30b0\u3092\u7d50\u5408\u3057\u3001\u300c\u5b9f\u7e3e\u306e\u3042\u308b\u300d\u30da\u30a2\u306e\u307f\u306b\u7d5e\u308b\nGROUP BY\n    T1.\u793e\u54e1ID, T1.\u5ba4ID      -- \u2461 \u793e\u54e1\u3068\u5ba4\u306e\u7d44\u307f\u5408\u308f\u305b\u3067\u30b0\u30eb\u30fc\u30d7\u5316\u3059\u308b\nHAVING\n    COUNT(*) >= 1           -- \u2463 \u30b0\u30eb\u30fc\u30d7\u5316\u3057\u305f\u7d50\u679c\u3001\u4ef6\u6570\u304c1\u4ef6\u4ee5\u4e0a\u306e\u3082\u306e\u3060\u3051\u3092\u6b8b\u3059\n<\/code><\/pre>\n<p>\u3053\u306eSQL\u306f\u3001\u756a\u53f7\u3092\u632f\u3063\u305f\u2460\u301c\u2463\u306e\u9806\u3067\u8ad6\u7406\u7684\u306b\u51e6\u7406\u3055\u308c\u3066\u3044\u304d\u307e\u3059\u3002\u5404\u30b9\u30c6\u30c3\u30d7\u306e\u5f79\u5272\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h3>INNER JOIN\uff1a\u5b9f\u7e3e\u306e\u3042\u308b\u7d44\u307f\u5408\u308f\u305b\u3060\u3051\u3092\u62bd\u51fa\u3059\u308b<\/h3>\n<p>\u6700\u521d\u306e\u30b9\u30c6\u30c3\u30d7\u306f<code>INNER JOIN<\/code>\uff08\u5185\u90e8\u7d50\u5408\uff09\u3067\u3059\u3002<code>INNER JOIN<\/code>\u306f\u3001\u6307\u5b9a\u3055\u308c\u305f\u6761\u4ef6\uff08<code>ON<\/code>\u53e5\uff09\u306b\u4e00\u81f4\u3059\u308b\u884c\u304c<strong>\u4e21\u65b9\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u5b58\u5728\u3059\u308b\u30c7\u30fc\u30bf\u3060\u3051<\/strong>\u3092\u7d50\u679c\u3068\u3057\u3066\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li><code>\u5165\u5ba4\u8a31\u53ef<\/code>\u30c6\u30fc\u30d6\u30eb\u306b\u306f\u3001\u300c\u793e\u54e1E001\u306f\u5ba4S101\u306b\u5165\u308c\u308b\u300d\u3068\u3044\u3046\u6a29\u9650\u60c5\u5831\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n<li><code>\u5165\u9000\u5ba4\u30ed\u30b0<\/code>\u30c6\u30fc\u30d6\u30eb\u306b\u306f\u3001\u904e\u53bb\u306e\u5165\u9000\u5ba4\u8a18\u9332\u304c\u84c4\u7a4d\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/li>\n<\/ul>\n<p><code>INNER JOIN<\/code>\u3067\u3053\u306e2\u3064\u3092\u7d50\u5408\u3059\u308b\u3068\u3001\u300c<code>\u5165\u5ba4\u8a31\u53ef<\/code>\u30c6\u30fc\u30d6\u30eb\u306b\u6a29\u9650\u304c\u3042\u308a\u3001<strong>\u304b\u3064<\/strong>\u3001<code>\u5165\u9000\u5ba4\u30ed\u30b0<\/code>\u30c6\u30fc\u30d6\u30eb\u306b\u5bfe\u5fdc\u3059\u308b\u5165\u5ba4\u8a18\u9332\u304c<strong>\u5b9f\u969b\u306b\u5b58\u5728\u3059\u308b<\/strong>\u300d\u7d44\u307f\u5408\u308f\u305b\u3060\u3051\u304c\u4e2d\u9593\u7d50\u679c\u3068\u3057\u3066\u6b8b\u308a\u307e\u3059\u3002\u9006\u306b\u5165\u5ba4\u8a31\u53ef\u306f\u3042\u3063\u3066\u3082\u4e00\u5ea6\u3082\u5165\u5ba4\u3057\u305f\u3053\u3068\u306e\u306a\u3044\uff08\u30ed\u30b0\u304c\u306a\u3044\uff09\u7d44\u307f\u5408\u308f\u305b\u306f\u3001\u3053\u306e\u6bb5\u968e\u3067\u8de1\u5f62\u3082\u306a\u304f\u6d88\u3048\u53bb\u308a\u307e\u3059\u3002<\/p>\n<h3>COUNT(*) \u3068 GROUP BY\uff1a\u300c\u7d44\u307f\u5408\u308f\u305b\u3054\u3068\u300d\u306b\u4ef6\u6570\u3092\u96c6\u8a08\u3059\u308b<\/h3>\n<p>\u6b21\u306b<code>GROUP BY T1.\u793e\u54e1ID, T1.\u5ba4ID<\/code>\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002\u3053\u308c\u306f\u3001<code>INNER JOIN<\/code>\u3092\u901a\u904e\u3057\u305f\u7d50\u679c\u30bb\u30c3\u30c8\u3092\u3001\u300c\u793e\u54e1ID\u3068\u5ba4ID\u306e\u30da\u30a2\u300d\u3067\u30b0\u30eb\u30fc\u30d7\u5206\u3051\u3059\u308b\u547d\u4ee4\u3067\u3059\u3002\u4f8b\u3048\u3070\u3001(E001, S101)\u306e\u30da\u30a2\u304c\u30ed\u30b0\u306b3\u56de\u8a18\u9332\u3055\u308c\u3066\u3044\u308c\u3070\u3001\u305d\u306e3\u884c\u304c1\u3064\u306e\u30b0\u30eb\u30fc\u30d7\u306b\u307e\u3068\u3081\u3089\u308c\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001<code>SELECT<\/code>\u53e5\u306e<code>COUNT(*)<\/code>\u304c\u3001\u3053\u306e<strong>\u30b0\u30eb\u30fc\u30d7\u3054\u3068\u306b<\/strong>\u884c\u6570\u3092\u30ab\u30a6\u30f3\u30c8\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>(E001, S101) \u306e\u30ed\u30b0\u304c3\u56de\u3042\u308c\u3070\u3001<code>COUNT(*)<\/code>\u306f <code>3<\/code> \u3068\u306a\u308a\u307e\u3059\u3002<\/li>\n<li>(E002, S205) \u306e\u30ed\u30b0\u304c10\u56de\u3042\u308c\u3070\u3001<code>COUNT(*)<\/code>\u306f <code>10<\/code> \u3068\u306a\u308a\u307e\u3059\u3002<\/li>\n<\/ul>\n<p>\u3053\u3053\u3067\u306e\u30dd\u30a4\u30f3\u30c8\u306f\u3001<code>INNER JOIN<\/code>\u3092\u7d4c\u7531\u3057\u3066\u3044\u308b\u305f\u3081\u3001<code>COUNT(*)<\/code>\u306e\u7d50\u679c\u304c <code>0<\/code> \u306b\u306a\u308b\u3053\u3068\u306f\u7d76\u5bfe\u306b\u306a\u3044\u3001\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<code>COUNT(*)<\/code>\u304c\u8a08\u7b97\u3055\u308c\u308b\u5bfe\u8c61\u306f\u3001\u3059\u3067\u306b\u5165\u5ba4\u5b9f\u7e3e\u304c\u3042\u308b\u30c7\u30fc\u30bf\u3060\u3051\u3060\u304b\u3089\u3067\u3059\u3002<\/p>\n<h3>HAVING\u53e5\uff1a\u96c6\u8a08\u7d50\u679c\u3092\u6700\u7d42\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3059\u308b<\/h3>\n<p>\u6700\u5f8c\u306b<code>HAVING COUNT(*) >= 1<\/code>\u53e5\u3067\u3059\u3002<code>HAVING<\/code>\u306f\u3001<code>GROUP BY<\/code>\u3067\u96c6\u8a08\u3055\u308c\u305f\u5f8c\u306e\u7d50\u679c\u306b\u5bfe\u3057\u3066\u9069\u7528\u3055\u308c\u308b\u30d5\u30a3\u30eb\u30bf\u30fc\u3067\u3059\u3002<code>WHERE<\/code>\u53e5\u304c\u96c6\u8a08\u524d\u306e\u500b\u3005\u306e\u884c\u3092\u7d5e\u308a\u8fbc\u3080\u306e\u306b\u5bfe\u3057\u3001<code>HAVING<\/code>\u53e5\u306f\u300c\u5408\u8a08\u304c1000\u4ee5\u4e0a\u306e\u30b0\u30eb\u30fc\u30d7\u306e\u307f\u300d\u3084\u300c\u5e73\u5747\u70b9\u304c80\u70b9\u4ee5\u4e0a\u306e\u30af\u30e9\u30b9\u306e\u307f\u300d\u3068\u3044\u3063\u305f\u3001\u96c6\u8a08\u7d50\u679c\u306b\u5bfe\u3059\u308b\u6761\u4ef6\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306e<code>HAVING COUNT(*) >= 1<\/code>\u306f\u3001\u300c\u30b0\u30eb\u30fc\u30d7\u3054\u3068\u306e\u4ef6\u6570\u304c1\u4ef6\u4ee5\u4e0a\u306e\u3082\u306e\u300d\u3068\u3044\u3046\u6761\u4ef6\u3067\u3059\u304c\u3001\u524d\u8ff0\u306e\u901a\u308a<code>INNER JOIN<\/code>\u306b\u3088\u3063\u3066\u5b9f\u7e3e\u306e\u306a\u3044\u7d44\u307f\u5408\u308f\u305b\u306f\u6d88\u3048\u3066\u3044\u308b\u305f\u3081\u3001\u3059\u3079\u3066\u306e\u30b0\u30eb\u30fc\u30d7\u304c\u3053\u306e\u6761\u4ef6\u3092\u6e80\u305f\u3057\u307e\u3059\u3002\u3053\u308c\u306f\u3001SQL\u306e\u51e6\u7406\u3068\u3057\u3066\u5ff5\u306e\u305f\u3081\u8a18\u8ff0\u3055\u308c\u3066\u3044\u308b\u3001\u3042\u308b\u3044\u306f\u4ed6\u306e<code>JOIN<\/code>\uff08<code>LEFT JOIN<\/code>\u306a\u3069\uff09\u3092\u4f7f\u3063\u305f\u5834\u5408\u3067\u3082\u540c\u3058\u7d50\u679c\u3092\u5f97\u3089\u308c\u308b\u3088\u3046\u306b\u6c4e\u7528\u6027\u3092\u6301\u305f\u305b\u305f\u8a18\u8ff0\u3068\u89e3\u91c8\u3067\u304d\u307e\u3059\u3002<\/p>\n<div style=\"border: 2px solid #4a90e2; border-radius: 8px; padding: 16px; background-color: #f0f8ff; margin-top: 20px;\">\n<h4 style=\"color: #4a90e2; margin-top: 0;\">&#x1f7e6; \u30b3\u30e9\u30e0\uff1aINNER JOIN\u306e\u7279\u6027\u304c\u300c\u884c\u306a\u3057\u300d\u3092\u751f\u3080<\/h4>\n<p>\u3053\u306eSQL\u306e\u6700\u3082\u5de7\u5999\u306a\u70b9\u306f\u3001\u300c\u5b9f\u7e3e\u304c0\u4ef6\u300d\u3068\u3044\u3046\u60c5\u5831\u3092\u884c\u3068\u3057\u3066\u51fa\u529b\u3057\u306a\u3044\u90e8\u5206\u3067\u3059\u3002\u306a\u305c\u305d\u3046\u306a\u308b\u306e\u3067\u3057\u3087\u3046\u304b\uff1f<\/p>\n<p>\u305d\u308c\u306f\u3001<code>INNER JOIN<\/code>\u304c\u300c\u4e21\u30c6\u30fc\u30d6\u30eb\u306b\u4e00\u81f4\u3059\u308b\u30c7\u30fc\u30bf\u304c\u306a\u3051\u308c\u3070\u3001\u554f\u7b54\u7121\u7528\u3067\u7d50\u679c\u304b\u3089\u9664\u5916\u3059\u308b\u300d\u3068\u3044\u3046\u6027\u8cea\u3092\u6301\u3064\u305f\u3081\u3067\u3059\u3002\u5165\u5ba4\u8a31\u53ef\u304c\u3042\u3063\u3066\u3082\u4e00\u5ea6\u3082\u5165\u5ba4\u30ed\u30b0\u304c\u306a\u3044\u5834\u5408\u3001\u305d\u3082\u305d\u3082<code>JOIN<\/code>\u306e\u6bb5\u968e\u3067\u305d\u306e\u30c7\u30fc\u30bf\u306f\u6d88\u3048\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u305d\u306e\u5f8c\u306e<code>GROUP BY<\/code>\u3084<code>COUNT<\/code>\u306e\u96c6\u8a08\u5bfe\u8c61\u306b\u3059\u3089\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u7d50\u679c\u3068\u3057\u3066\u3001\u3053\u306eSQL\u304b\u3089\u5f97\u3089\u308c\u308b\u306e\u306f\u4ee5\u4e0b\u306e2\u30d1\u30bf\u30fc\u30f3\u3060\u3051\u3067\u3059\u3002<\/p>\n<ul>\n<li><strong>\u5b9f\u7e3e\u304c\u3042\u308b\u5834\u5408\uff1a<\/strong><code>JOIN<\/code>\u304c\u6210\u529f\u3057\u3001\u30b0\u30eb\u30fc\u30d7\u5316\u3055\u308c\u3001<code>COUNT(*)<\/code>\u3067\u5b9f\u7e3e\u56de\u6570\uff081\u4ee5\u4e0a\uff09\u304c\u8a08\u7b97\u3055\u308c\u305f\u884c\u304c\u51fa\u529b\u3055\u308c\u308b\u3002<\/li>\n<li><strong>\u5b9f\u7e3e\u304c\u306a\u3044\u5834\u5408\uff1a<\/strong><code>JOIN<\/code>\u304c\u5931\u6557\u3057\u3001<strong>\u884c\u305d\u306e\u3082\u306e\u304c\u5b58\u5728\u3057\u306a\u3044 (NULL\u3067\u306f\u306a\u304f\u975e\u5b58\u5728)<\/strong>\u3002<\/li>\n<\/ul>\n<p>\u3064\u307e\u308a\u3001<code>COUNT<\/code>\u306e\u7d50\u679c\u304c\u300c0\u304b1\u304b\u300d\u3068\u3044\u3046\u6570\u5024\u30ec\u30d9\u30eb\u306e\u5224\u5b9a\u3067\u306f\u306a\u304f\u3001\u300c\u884c\u304c\u5b58\u5728\u3059\u308b\u304b\u3001\u3057\u306a\u3044\u304b\u300d\u3068\u3044\u3046\u69cb\u9020\u30ec\u30d9\u30eb\u306e\u5224\u5b9a\u306b\u5909\u63db\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3059\u3002\u3053\u308c\u304c\u3001\u8a2d\u554f\u306e\u8981\u4ef6\u3092\u6e80\u305f\u3059\u30ab\u30e9\u30af\u30ea\u3067\u3059\u3002<\/p>\n<\/div>\n<h2>\u8a2d\u554f\u2463 \u81ea\u5df1\u7d50\u5408(Self Join)\u5b8c\u5168\u7406\u89e3\uff1a\u7d44\u7e54\u8868T1, T2, T3\u306e\u968e\u5c64\u5c55\u958b\u30c8\u30ea\u30c3\u30af<\/h2>\n<p>\u6700\u5f8c\u306e\u8a2d\u554f\u2463\u306f\u3001\u591a\u304f\u306e\u53d7\u9a13\u8005\u304c\u82e6\u624b\u3068\u3059\u308b\u300c\u81ea\u5df1\u7d50\u5408\uff08\u30bb\u30eb\u30d5\u30b8\u30e7\u30a4\u30f3\uff09\u300d\u306b\u95a2\u3059\u308b\u554f\u984c\u3067\u3059\u30021\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u3092<code>T1<\/code>, <code>T2<\/code>, <code>T3<\/code>\u3068\u3044\u3063\u305f\u7570\u306a\u308b\u5225\u540d\u3092\u4ed8\u3051\u3066\u4f55\u5ea6\u3082\u7d50\u5408\u3059\u308b\u306e\u306f\u306a\u305c\u304b\u3002\u3053\u308c\u306f\u3001\u30c6\u30fc\u30d6\u30eb\u5185\u306b\u5b58\u5728\u3059\u308b\u300c\u968e\u5c64\u69cb\u9020\u300d\u306e\u60c5\u5831\u3092\u30011\u884c\u306e\u30ec\u30b3\u30fc\u30c9\u3068\u3057\u3066\u30d5\u30e9\u30c3\u30c8\u306b\u5c55\u958b\u3059\u308b\u305f\u3081\u306e\u3001SQL\u306b\u304a\u3051\u308b\u975e\u5e38\u306b\u5f37\u529b\u306a\u30c6\u30af\u30cb\u30c3\u30af\u306a\u306e\u3067\u3059\u3002<\/p>\n<h3>\u300c\u7d44\u7e54\u300d\u30c6\u30fc\u30d6\u30eb\u306f\u81ea\u5206\u81ea\u8eab\u3092\u53c2\u7167\u3059\u308b\u300c\u81ea\u5df1\u53c2\u7167\u69cb\u9020\u300d<\/h3>\n<p>\u307e\u305a\u3001\u300c\u7d44\u7e54\u300d\u30c6\u30fc\u30d6\u30eb\u306e\u69cb\u9020\u7684\u7279\u5fb4\u3092\u7406\u89e3\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u306f\u3001\u5404\u7d44\u7e54\u3092\u8b58\u5225\u3059\u308b<code>\u7d44\u7e54ID<\/code>\uff08\u4e3b\u30ad\u30fc\uff09\u3068\u3001\u305d\u306e\u7d44\u7e54\u304c\u6240\u5c5e\u3059\u308b\u4e00\u3064\u4e0a\u306e\u7d44\u7e54\u3092\u793a\u3059<code>\u4e0a\u4f4d\u7d44\u7e54ID`\uff08\u5916\u90e8\u30ad\u30fc\uff09\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<table border=\"1\" style=\"width:100%; border-collapse: collapse;\">\n<thead>\n<tr>\n<th style=\"padding: 8px; background-color: #f2f2f2;\">\u7d44\u7e54ID (PK)<\/th>\n<th style=\"padding: 8px; background-color: #f2f2f2;\">\u7d44\u7e54\u540d<\/th>\n<th style=\"padding: 8px; background-color: #f2f2f2;\">\u4e0a\u4f4d\u7d44\u7e54ID (FK)<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding: 8px;\">D10<\/td>\n<td style=\"padding: 8px;\">\u958b\u767a1\u8ab2<\/td>\n<td style=\"padding: 8px;\">D01<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 8px;\">D20<\/td>\n<td style=\"padding: 8px;\">\u958b\u767a2\u8ab2<\/td>\n<td style=\"padding: 8px;\">D01<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 8px;\">D01<\/td>\n<td style=\"padding: 8px;\">\u958b\u767a\u90e8<\/td>\n<td style=\"padding: 8px;\">H01<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 8px;\">S10<\/td>\n<td style=\"padding: 8px;\">\u55b6\u696d1\u8ab2<\/td>\n<td style=\"padding: 8px;\">S01<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 8px;\">S01<\/td>\n<td style=\"padding: 8px;\">\u55b6\u696d\u90e8<\/td>\n<td style=\"padding: 8px;\">H01<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 8px;\">H01<\/td>\n<td style=\"padding: 8px;\">\u672c\u793e<\/td>\n<td style=\"padding: 8px;\">NULL<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6ce8\u76ee\u3059\u3079\u304d\u306f\u3001<code>\u4e0a\u4f4d\u7d44\u7e54ID<\/code>\u304c\u3001\u540c\u3058\u300c\u7d44\u7e54\u300d\u30c6\u30fc\u30d6\u30eb\u5185\u306e<code>\u7d44\u7e54ID<\/code>\u3092\u53c2\u7167\u3057\u3066\u3044\u308b\u70b9\u3067\u3059\u3002\u4f8b\u3048\u3070\u3001\u300c\u958b\u767a1\u8ab2\uff08D10\uff09\u300d\u306e<code>\u4e0a\u4f4d\u7d44\u7e54ID<\/code>\u306f\u300cD01\u300d\u3067\u3059\u304c\u3001\u3053\u308c\u306f\u300c\u958b\u767a\u90e8\u300d\u306e<code>\u7d44\u7e54ID<\/code>\u3092\u6307\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u3088\u3046\u306b\u3001\u3042\u308b\u30ec\u30b3\u30fc\u30c9\u304c\u540c\u3058\u30c6\u30fc\u30d6\u30eb\u5185\u306e\u5225\u30ec\u30b3\u30fc\u30c9\u3092\u89aa\u5b50\u95a2\u4fc2\u306e\u3088\u3046\u306b\u53c2\u7167\u3059\u308b\u69cb\u9020\u3092<strong>\u300c\u81ea\u5df1\u53c2\u7167\u69cb\u9020\u300d<\/strong>\u307e\u305f\u306f<strong>\u300c\u518d\u5e30\u7684\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u30b7\u30c3\u30d7\u300d<\/strong>\u3068\u547c\u3073\u307e\u3059\u3002<\/p>\n<h3>1\u3064\u306e\u8868\u3092\u968e\u5c64\u3054\u3068\u306bJOIN\u3057\u3066\u300c\u5217\u300d\u3068\u3057\u3066\u5c55\u958b\u3059\u308b<\/h3>\n<p>\u3053\u306e\u81ea\u5df1\u53c2\u7167\u69cb\u9020\u306f\u3001\u5c11\u306a\u3044\u30c7\u30fc\u30bf\u3067\u968e\u5c64\u3092\u8868\u73fe\u3067\u304d\u308b\u53cd\u9762\u3001\u300c\u958b\u767a1\u8ab2\u306e\u4e0a\u4f4d\u7d44\u7e54\u3067\u3042\u308b\u958b\u767a\u90e8\u306e\u3001\u3055\u3089\u306b\u4e0a\u4f4d\u306e\u7d44\u7e54\u3067\u3042\u308b\u672c\u793e\u306e\u540d\u524d\u306f\uff1f\u300d\u3068\u3044\u3063\u305f\u3001\u968e\u5c64\u3092\u8907\u6570\u307e\u305f\u3050\u60c5\u5831\u3092\u4e00\u5ea6\u306b\u53d6\u5f97\u3059\u308b\u306e\u304c\u56f0\u96e3\u3067\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u81ea\u5df1\u7d50\u5408\u306e\u51fa\u756a\u3067\u3059\u3002SQL\u306f\u3001\u300c\u7d44\u7e54\u300d\u30c6\u30fc\u30d6\u30eb\u3092<strong>\u5f79\u5272\u306e\u7570\u306a\u308b\u8907\u6570\u306e\u4eee\u60f3\u7684\u306a\u30c6\u30fc\u30d6\u30eb<\/strong>\u3068\u898b\u306a\u3059\u3053\u3068\u3067\u3001\u3053\u306e\u554f\u984c\u3092\u89e3\u6c7a\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li><code>\u7d44\u7e54 AS T1<\/code> \u2192 \u6700\u4e0b\u5c64\u306e\u7d44\u7e54\uff08\u4f8b\uff1a\u8ab2\uff09\u306e\u60c5\u5831\u3092\u62c5\u5f53\u3059\u308b\u4eee\u60f3\u30c6\u30fc\u30d6\u30eb<\/li>\n<li><code>\u7d44\u7e54 AS T2<\/code> \u2192 \u4e2d\u9593\u5c64\u306e\u7d44\u7e54\uff08\u4f8b\uff1a\u90e8\uff09\u306e\u60c5\u5831\u3092\u62c5\u5f53\u3059\u308b\u4eee\u60f3\u30c6\u30fc\u30d6\u30eb<\/li>\n<li><code>\u7d44\u7e54 AS T3<\/code> \u2192 \u6700\u4e0a\u5c64\u306e\u7d44\u7e54\uff08\u4f8b\uff1a\u672c\u793e\uff09\u306e\u60c5\u5831\u3092\u62c5\u5f53\u3059\u308b\u4eee\u60f3\u30c6\u30fc\u30d6\u30eb<\/li>\n<\/ul>\n<p>\u540c\u3058\u30c6\u30fc\u30d6\u30eb\u30923\u56de\u767b\u5834\u3055\u305b\u3001\u305d\u308c\u305e\u308c\u306b<code>T1<\/code>, <code>T2<\/code>, <code>T3<\/code>\u3068\u3044\u3046\u5225\u540d\uff08\u30a8\u30a4\u30ea\u30a2\u30b9\uff09\u3092\u4ed8\u3051\u3001\u3053\u308c\u3089\u3092\u7d50\u5408\u3057\u3066\u3044\u304f\u3053\u3068\u3067\u3001\u672c\u6765\u306f\u8907\u6570\u884c\u306b\u5206\u304b\u308c\u3066\u3044\u305f\u968e\u5c64\u60c5\u5831\u3092\u3001<strong>1\u884c\u306e\u30ec\u30b3\u30fc\u30c9\u306e\u4e2d\u306b\u300c\u8ab2\u306e\u540d\u524d\u300d\u300c\u90e8\u306e\u540d\u524d\u300d\u300c\u672c\u793e\u306e\u540d\u524d\u300d\u3068\u3044\u3063\u305f\u5f62\u3067\u5217\u3068\u3057\u3066\u5c55\u958b<\/strong>\u3067\u304d\u308b\u306e\u3067\u3059\u3002<\/p>\n<h3>JOIN\u6761\u4ef6\u306e\u610f\u5473\uff08T1 \u2192 T2 \u2192 T3\uff09<\/h3>\n<p>\u3067\u306f\u3001\u5177\u4f53\u7684\u306a<code>JOIN<\/code>\u306e\u30ed\u30b8\u30c3\u30af\u3092\u8ffd\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u3053\u308c\u306f\u3001\u968e\u5c64\u306e\u201c\u4e0b\u304b\u3089\u4e0a\u3078\u201d\u3068\u9061\u3063\u3066\u3044\u304f\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u3002<\/p>\n<pre><code>FROM\n    \u7d44\u7e54 AS T1\nINNER JOIN\n    \u7d44\u7e54 AS T2 ON T1.\u4e0a\u4f4d\u7d44\u7e54ID = T2.\u7d44\u7e54ID\nINNER JOIN\n    \u7d44\u7e54 AS T3 ON T2.\u4e0a\u4f4d\u7d44\u7e54ID = T3.\u7d44\u7e54ID\n<\/code><\/pre>\n<ol>\n<li><strong><code>T1<\/code>\u3092\u57fa\u70b9\u3068\u3059\u308b<\/strong><br \/>\u307e\u305a\u3001<code>T1<\/code>\u3092\u57fa\u6e96\u3068\u306a\u308b\u6700\u4e0b\u5c64\u306e\u7d44\u7e54\uff08\u4f8b\uff1a\u300c\u958b\u767a1\u8ab2\u300d\uff09\u3068\u3057\u307e\u3059\u3002<\/li>\n<li><strong><code>T1<\/code>\u3068<code>T2<\/code>\u3092JOIN<\/strong><br \/>\u6b21\u306b\u3001<code>T1.\u4e0a\u4f4d\u7d44\u7e54ID = T2.\u7d44\u7e54ID<\/code>\u3068\u3044\u3046\u6761\u4ef6\u3067\u7d50\u5408\u3057\u307e\u3059\u3002\u3053\u308c\u306f\u3001\u300c<code>T1<\/code>\uff08\u958b\u767a1\u8ab2\uff09\u306e\u4e0a\u4f4d\u7d44\u7e54ID\uff08D01\uff09\u3068\u3001<code>T2<\/code>\u306e\u7d44\u7e54ID\u304c\u4e00\u81f4\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u300d\u3092\u63a2\u3059\u51e6\u7406\u3067\u3059\u3002\u7d50\u679c\u3068\u3057\u3066\u3001<code>T2<\/code>\u306f\u300c\u958b\u767a\u90e8\u300d\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u6307\u3059\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u306e\u6642\u70b9\u3067\u30011\u3064\u306e\u884c\u306b\u300c\u958b\u767a1\u8ab2\u306e\u60c5\u5831\u300d\u3068\u300c\u958b\u767a\u90e8\u306e\u60c5\u5831\u300d\u304c\u4e26\u3073\u307e\u3059\u3002<\/li>\n<li><strong><code>T2<\/code>\u3068<code>T3<\/code>\u3092JOIN<\/strong><br \/>\u3055\u3089\u306b\u3001<code>T2.\u4e0a\u4f4d\u7d44\u7e54ID = T3.\u7d44\u7e54ID<\/code>\u3067\u7d50\u5408\u3057\u307e\u3059\u3002\u3053\u308c\u306f\u3001\u300c<code>T2<\/code>\uff08\u958b\u767a\u90e8\uff09\u306e\u4e0a\u4f4d\u7d44\u7e54ID\uff08H01\uff09\u3068\u3001<code>T3<\/code>\u306e\u7d44\u7e54ID\u304c\u4e00\u81f4\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u300d\u3092\u63a2\u3059\u51e6\u7406\u3067\u3059\u3002\u7d50\u679c\u3068\u3057\u3066\u3001<code>T3<\/code>\u306f\u300c\u672c\u793e\u300d\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u6307\u3057\u307e\u3059\u3002<\/li>\n<\/ol>\n<p>\u6700\u7d42\u7684\u306b\u3001<code>SELECT T1.\u7d44\u7e54\u540d, T2.\u7d44\u7e54\u540d, T3.\u7d44\u7e54\u540d<\/code>\u3068\u3059\u308c\u3070\u3001\u300c\u958b\u767a1\u8ab2, \u958b\u767a\u90e8, \u672c\u793e\u300d\u3068\u3044\u3046\u3001\u968e\u5c64\u304c\u5217\u3068\u3057\u3066\u5c55\u958b\u3055\u308c\u305f1\u884c\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3067\u304d\u308b\u306e\u3067\u3059\u3002<\/p>\n<h3>\u767a\u5c55\uff1a\u53ef\u5909\u9577\u306e\u968e\u5c64\u306b\u306f\u300c\u518d\u5e30CTE\u300d\u3092\u4f7f\u3046<\/h3>\n<p>\u3053\u306e\u81ea\u5df1\u7d50\u5408\u306f\u975e\u5e38\u306b\u5f37\u529b\u3067\u3059\u304c\u3001\u300c\u968e\u5c64\u306e\u6df1\u3055\u304c\u56fa\u5b9a\u300d\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u306b\u3057\u304b\u4f7f\u3048\u307e\u305b\u3093\u3002\u3082\u3057\u7d44\u7e54\u306e\u968e\u5c64\u304c\u90e8\u7f72\u306b\u3088\u3063\u30663\u968e\u5c64\u3060\u3063\u305f\u308a5\u968e\u5c64\u3060\u3063\u305f\u308a\u3059\u308b\u5834\u5408\u3001<code>JOIN`\u3092\u3044\u304f\u3064\u66f8\u3051\u3070\u3088\u3044\u304b\u5206\u304b\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u3053\u306e\u3088\u3046\u306a\u53ef\u5909\u9577\u306e\u968e\u5c64\u69cb\u9020\u3092\u6271\u3046\u305f\u3081\u306b\u3001\u73fe\u5728\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u306f<strong>\u300c\u518d\u5e30CTE\uff08\u5171\u901a\u30c6\u30fc\u30d6\u30eb\u5f0f\uff09\u300d<\/strong>\u3068\u3044\u3046\u3001\u3088\u308a\u9ad8\u5ea6\u306a\u6a5f\u80fd\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<code>WITH RECURSIVE<\/code>\u3068\u3044\u3063\u305f\u69cb\u6587\u3092\u4f7f\u3044\u3001\u968e\u5c64\u306e\u672b\u7aef\u306b\u5230\u9054\u3059\u308b\u307e\u3067\u81ea\u52d5\u7684\u306b\u7e70\u308a\u8fd4\u3057\u554f\u3044\u5408\u308f\u305b\u3092\u5b9f\u884c\u3059\u308b\u4ed5\u7d44\u307f\u3067\u3059\u3002\u5fdc\u7528\u60c5\u5831\u6280\u8853\u8005\u8a66\u9a13\u306e\u7bc4\u56f2\u3092\u5c11\u3057\u8d85\u3048\u307e\u3059\u304c\u3001\u5b9f\u52d9\u3067\u306f\u983b\u51fa\u3059\u308b\u91cd\u8981\u306a\u30c6\u30af\u30cb\u30c3\u30af\u3068\u3057\u3066\u899a\u3048\u3066\u304a\u304f\u3068\u3088\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<div style=\"border: 2px solid #50b363; border-radius: 8px; padding: 16px; background-color: #f0fff4; margin-top: 20px;\">\n<h4 style=\"color: #50b363; margin-top: 0;\">&#x1f7e9; \u30b3\u30e9\u30e0\uff1aT1, T2, T3... \u306e\u6570\u5b57\u304c\u5927\u304d\u304f\u306a\u308b\u7406\u7531<\/h4>\n<p>\u81ea\u5df1\u7d50\u5408\u3067\u4f7f\u3046\u5225\u540d\u306e\u6570\u5b57\u304c <code>T1<\/code> \u2192 <code>T2<\/code> \u2192 <code>T3<\/code> \u3068\u5897\u3048\u3066\u3044\u304f\u306e\u306b\u306f\u3001\u6163\u7fd2\u7684\u306a\u610f\u5473\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u306fSQL\u306e\u6587\u6cd5\u30eb\u30fc\u30eb\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u591a\u304f\u306e\u958b\u767a\u8005\u304c\u5f93\u3046\u300c\u8aad\u307f\u3084\u3059\u3055\u300d\u306e\u305f\u3081\u306e\u4f5c\u6cd5\u3067\u3059\u3002<\/p>\n<p>\u4e00\u822c\u7684\u306b\u3001<strong>\u968e\u5c64\u69cb\u9020\u306e\u6700\u3082\u4e0b\uff08\u672b\u7aef\u3001\u5b50\uff09\u3092<code>T1<\/code>\u3068\u3057\u3001\u968e\u5c64\u3092\u4e00\u6bb5\u4e0a\u304c\u308b\uff08\u89aa\u3092\u305f\u3069\u308b\uff09\u3054\u3068\u306b\u6570\u5b57\u30921\u3064\u5897\u3084\u3057\u3066\u3044\u304f<\/strong>\u3001\u3068\u3044\u3046\u30eb\u30fc\u30eb\u3067\u547d\u540d\u3055\u308c\u307e\u3059\u3002<\/p>\n<ul>\n<li><code>T1<\/code>\uff1a\u81ea\u5206\u81ea\u8eab\uff08\u4f8b\uff1a\u8ab2\uff09<\/li>\n<li><code>T2<\/code>\uff1a\u89aa\uff08\u4f8b\uff1a\u90e8\uff09<\/li>\n<li><code>T3<\/code>\uff1a\u7956\u7236\uff08\u4f8b\uff1a\u672c\u793e\uff09<\/li>\n<\/ul>\n<p>\u3053\u306e\u3088\u3046\u306b\u547d\u540d\u3059\u308b\u3053\u3068\u3067\u3001SQL\u30b3\u30fc\u30c9\u3092\u4e00\u8aad\u3057\u305f\u3060\u3051\u3067\u300c\u3042\u3042\u3001\u3053\u308c\u306f\u968e\u5c64\u3092\u4e0b\u304b\u3089\u4e0a\u306b3\u6bb5\u968e\u9061\u3063\u3066\u3044\u308b\u306e\u3060\u306a\u300d\u3068\u3001\u51e6\u7406\u306e\u610f\u56f3\u3092\u76f4\u611f\u7684\u306b\u7406\u89e3\u3057\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002\u5bb6\u7cfb\u56f3\u3092\u305f\u3069\u308b\u3088\u3046\u306b\u3001\u6570\u5b57\u304c\u5927\u304d\u3044\u307b\u3069\u201c\u5148\u7956\u201d\u3092\u8868\u3059\u3068\u8003\u3048\u308b\u3068\u5206\u304b\u308a\u3084\u3059\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<\/div>\n<h2>\u672c\u8cea\u3092\u7406\u89e3\u3057\u5fdc\u7528\u3078\uff1a\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u5348\u5f8c\u554f\u984c\u653b\u7565\u306e4\u3064\u306e\u9375<\/h2>\n<p>\u5e73\u621030\u5e74\u79cb\u5b63\u306e\u300c\u5165\u5ba4\u7ba1\u7406\u30b7\u30b9\u30c6\u30e0\u300d\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u5348\u5f8c\u554f\u984c\u3092\u653b\u7565\u3059\u308b\u305f\u3081\u306e\u30a8\u30c3\u30bb\u30f3\u30b9\u304c\u51dd\u7e2e\u3055\u308c\u305f\u975e\u5e38\u306b\u5b66\u3073\u306e\u591a\u3044\u4e00\u554f\u3067\u3057\u305f\u3002\u672c\u8a18\u4e8b\u3067\u89e3\u8aac\u3057\u3066\u304d\u305f4\u3064\u306e\u8a2d\u554f\u306f\u3001\u305d\u308c\u305e\u308c\u304c\u72ec\u7acb\u3057\u305f\u77e5\u8b58\u3092\u554f\u3046\u3066\u3044\u308b\u3088\u3046\u3067\u3001\u5b9f\u306f\u6df1\u304f\u95a2\u9023\u3057\u5408\u3063\u3066\u3044\u307e\u3059\u3002\u6700\u5f8c\u306b\u3001\u5404\u8a2d\u554f\u304b\u3089\u5f97\u3089\u308c\u308b\u6559\u8a13\u3092\u632f\u308a\u8fd4\u308a\u3001\u5408\u683c\u306b\u5411\u3051\u305f\u666e\u904d\u7684\u306a\u5b66\u7fd2\u6307\u91dd\u3092\u63b4\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<ul style=\"list-style-type: none; padding-left: 0;\">\n<li style=\"margin-bottom: 1em;\">&#x2705; <strong>\u8a2d\u554f\u2460 ER\u56f3\u306e\u7dda\uff1d\u5916\u90e8\u30ad\u30fc\u306e\u53c2\u7167\u95a2\u4fc2<\/strong><br \/>\n    ER\u56f3\u306e\u7dda\u306f\u3001\u5358\u306a\u308b\u6982\u5ff5\u7684\u306a\u300c\u3064\u306a\u304c\u308a\u300d\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u305d\u308c\u306f\u5916\u90e8\u30ad\u30fc\u5236\u7d04\u306b\u3088\u3063\u3066\u30c7\u30fc\u30bf\u306e\u6574\u5408\u6027\u304c\u62c5\u4fdd\u3055\u308c\u305f\u3001\u7269\u7406\u7684\u306a\u300c\u53c2\u7167\u95a2\u4fc2\u300d\u306e\u73fe\u308c\u3067\u3059\u3002\u30c7\u30fc\u30bf\u306e<strong>\u69cb\u9020<\/strong>\u3092\u6b63\u3057\u304f\u8aad\u307f\u89e3\u304f\u529b\u304c\u3001\u3059\u3079\u3066\u306e\u57fa\u672c\u3068\u306a\u308a\u307e\u3059\u3002<\/li>\n<li style=\"margin-bottom: 1em;\">&#x2705; <strong>\u8a2d\u554f\u2461 \u8907\u5408\u4e3b\u30ad\u30fc\uff1d\u591a\u5bfe\u591a\u3092\u6b63\u898f\u5316\u3057\u305f\u7d50\u679c<\/strong><br \/>\n    \u8907\u5408\u4e3b\u30ad\u30fc\u306f\u3001\u73fe\u5b9f\u4e16\u754c\u306e\u8907\u96d1\u306a\u300c\u591a\u5bfe\u591a\u300d\u306e<strong>\u95a2\u4fc2\u6027<\/strong>\u3092\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u4e0a\u3067\u77db\u76fe\u306a\u304f\u8868\u73fe\u3059\u308b\u305f\u3081\u306e\u5fc5\u7136\u7684\u306a\u8a2d\u8a08\u3067\u3059\u3002\u306a\u305c\u305d\u308c\u304c\u5fc5\u8981\u306a\u306e\u304b\u3092\u6b63\u898f\u5316\u306e\u89b3\u70b9\u304b\u3089\u7406\u89e3\u3059\u308b\u3053\u3068\u3067\u3001\u30c6\u30fc\u30d6\u30eb\u8a2d\u8a08\u306e\u610f\u56f3\u3092\u6df1\u304f\u8aad\u307f\u53d6\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/li>\n<li style=\"margin-bottom: 1em;\">&#x2705; <strong>\u8a2d\u554f\u2462 INNER JOIN\uff0bCOUNT(*)\u3067\u5b58\u5728\u3092\u5224\u5b9a<\/strong><br \/>\n    SQL\u306f\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u51fa\u3059\u3060\u3051\u306e\u30c4\u30fc\u30eb\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<code>INNER JOIN<\/code>\u306e\u300c\u4e00\u81f4\u3059\u308b\u884c\u306e\u307f\u300d\u3068\u3044\u3046\u6027\u8cea\u3068\u96c6\u7d04\u95a2\u6570\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u300c\u30c7\u30fc\u30bf\u304c\u5b58\u5728\u3059\u308b\u304b\u5426\u304b\u300d\u3092\u5224\u5b9a\u3059\u308b<strong>\u8ad6\u7406<\/strong>\u7684\u306a\u9053\u5177\u3068\u3057\u3066\u6d3b\u7528\u3067\u304d\u307e\u3059\u3002SQL\u306e\u6319\u52d5\u3092\u6839\u672c\u304b\u3089\u7406\u89e3\u3059\u308b\u3053\u3068\u304c\u3001\u5fdc\u7528\u7684\u306a\u554f\u984c\u89e3\u6c7a\u306b\u7e4b\u304c\u308a\u307e\u3059\u3002<\/li>\n<li style=\"margin-bottom: 1em;\">&#x2705; <strong>\u8a2d\u554f\u2463 \u81ea\u5df1\u7d50\u5408\u3067\u968e\u5c64\u3092\u5c55\u958b<\/strong><br \/>\n    \u81ea\u5df1\u7d50\u5408\uff08\u30bb\u30eb\u30d5\u30b8\u30e7\u30a4\u30f3\uff09\u306f\u3001\u4e00\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u5185\u306b\u683c\u7d0d\u3055\u308c\u305f<strong>\u968e\u5c64<\/strong>\u69cb\u9020\u3092\u3001\u5206\u6790\u3057\u3084\u3059\u3044\u6a2a\u6301\u3061\u306e\u30c7\u30fc\u30bf\uff08\u5217\uff09\u306b\u5c55\u958b\u3059\u308b\u305f\u3081\u306e\u5fc5\u9808\u30c6\u30af\u30cb\u30c3\u30af\u3067\u3059\u3002\u540c\u3058\u30c6\u30fc\u30d6\u30eb\u306b\u5225\u540d\u3092\u4e0e\u3048\u3066\u5f79\u5272\u5206\u62c5\u3055\u305b\u308b\u3068\u3044\u3046\u767a\u60f3\u304c\u3001\u6271\u3048\u308b\u30c7\u30fc\u30bf\u306e\u5e45\u3092\u5927\u304d\u304f\u5e83\u3052\u307e\u3059\u3002<\/li>\n<\/ul>\n<p>\u3053\u308c\u30894\u3064\u306e\u30dd\u30a4\u30f3\u30c8\u306f\u3001\u300c<strong>\u69cb\u9020 \u2192 \u95a2\u4fc2 \u2192 \u8ad6\u7406 \u2192 \u968e\u5c64<\/strong>\u300d\u3068\u3044\u3046\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u7406\u89e3\u3059\u308b\u4e0a\u3067\u306e\u91cd\u8981\u306a\u601d\u8003\u306e\u6d41\u308c\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002\u8868\u9762\u7684\u306aSQL\u69cb\u6587\u3084\u7528\u8a9e\u306e\u6697\u8a18\u306b\u7559\u307e\u3089\u305a\u3001\u305d\u306e\u80cc\u666f\u306b\u3042\u308b\u300c\u306a\u305c\u3053\u3046\u306a\u3063\u3066\u3044\u308b\u306e\u304b\u300d\u3068\u3044\u3046\u672c\u8cea\u3092\u5e38\u306b\u610f\u8b58\u3059\u308b\u3053\u3068\u304c\u3001\u5fdc\u7528\u60c5\u5831\u6280\u8853\u8005\u8a66\u9a13\u306e\u5348\u5f8c\u554f\u984c\u3092\u5b89\u5b9a\u3057\u3066\u653b\u7565\u3059\u308b\u305f\u3081\u306e\u6700\u77ed\u30eb\u30fc\u30c8\u3068\u8a00\u3048\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5fdc\u7528\u60c5\u5831\u6280\u8853\u8005\u8a66\u9a13\u306e\u5348\u5f8c\u554f\u984c\u3001\u305d\u306e\u4e2d\u3067\u3082\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u5206\u91ce\u306f\u3001\u591a\u304f\u306e\u53d7\u9a13\u8005\u304c\u82e6\u6226\u3059\u308b\u4e00\u65b9\u3067\u3001\u5b9f\u52d9\u306b\u76f4\u7d50\u3059\u308b\u91cd\u8981\u306a\u77e5\u8b58\u304c\u554f\u308f\u308c\u308b\u9818\u57df\u3067\u3059\u3002\u7279\u306b\u5e73\u621030\u5e74\u79cb\u5b63\u306e\u554f2\u300c\u5165\u5ba4\u7ba1\u7406\u30b7\u30b9\u30c6\u30e0\u300d\u306f\u3001\u5358\u306a\u308bSQL\u306e\u77e5\u8b58 &#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-6154","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\/6154","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=6154"}],"version-history":[{"count":0,"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/posts\/6154\/revisions"}],"wp:attachment":[{"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/media?parent=6154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/categories?post=6154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sky-peace.net\/certified\/wp-json\/wp\/v2\/tags?post=6154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}