{"id":7001,"date":"2020-04-17T15:00:33","date_gmt":"2020-04-17T06:00:33","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=7001"},"modified":"2020-04-17T17:17:56","modified_gmt":"2020-04-17T08:17:56","slug":"__trashed-2","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=7001","title":{"rendered":"MySQL\u300cGROUP BY\u300d\u30a8\u30e9\u30fc\u89e3\u6c7a\u6cd5\u30fb\u5168\uff14\u4ef6"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u308c\u306f\u958b\u767a\u8005\u304c\u305f\u307e\u306b\u906d\u9047\u3059\u308b\u300c\u3042\u308b\u3042\u308b\u300d\u306a\u8a71\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001<code>DB<\/code>\u304b\u3089<code>GROUP BY<\/code>\u3067\u30c7\u30fc\u30bf\u53d6\u5f97\u3059\u308b\u3068\u304d\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u3053\u3068\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<blockquote><p><strong>Syntax error or access violation: 1055<\/strong> Expression #\uff08\u6570\u5b57\uff09 of SELECT list is not in GROUP BY clause and contains nonaggregated column &#8216;\uff08\u30d5\u30a3\u30fc\u30eb\u30c9\u540d\uff09&#8217; which is not functionally dependent on columns in GROUP BY clause; this is incompatible with <strong>sql_mode=only_full_group_by<\/strong> (SQL: select \uff08\u30d5\u30a3\u30fc\u30eb\u30c9\u540d\uff09, id from \uff08\u30c6\u30fc\u30d6\u30eb\u540d\uff09 group by \uff08\u30b0\u30eb\u30fc\u30d7\u5316\u30d5\u30a3\u30fc\u30eb\u30c9\u540d\uff09)<\/p><\/blockquote>\n<p>\u3053\u306e\u3053\u3068\u3092\u500b\u4eba\u7684\u306b\u300c<strong>ONLY_FULL_GROUP_BY\u554f\u984c<\/strong>\u300d\u3068\u547c\u3093\u3067\u3044\u308b\u306e\u3067\u3059\u304c\u3001<strong>\u306a\u305c\u3053\u306e\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u306e\u304b\u3092\u77e5\u3063\u3066\u304a\u304b\u306a\u3044\u3068\u3001\u9577\u6642\u9593\u30cf\u30de\u3063\u3066\u3057\u307e\u3046\u3053\u3068\u3082\u3042\u3063\u305f\u308a\u3057\u307e\u3059\u3002<\/strong><\/p>\n<p>\u305d\u3053\u3067\uff01<\/p>\n<p>\u4eca\u56de\u306f<code>GROUP BY<\/code>\u3057\u305f\u3068\u304d\u306e\u30a8\u30e9\u30fc\u306b\u3064\u3044\u3066\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<br \/>\n\u305c\u3072\u7686\u3055\u3093\u306e\u304a\u5f79\u306b\u7acb\u3066\u308b\u3068\u5b09\u3057\u3044\u3067\u3059\ud83d\ude0a\u2728<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6066 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_23.png\" alt=\"\" width=\"370\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_23.png 370w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_23-300x259.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><\/p>\n<p style=\"text-align: center;\">\u300c\u304b\u304f\u8a00\u3046\u79c1\u3082\u3088\u304f\u30cf\u30de\u3063\u3066\u307e\u3057\u305f\ud83d\ude02\u300d<\/p>\n<h1>\u3069\u3093\u306a\u6642\u306b\u30a8\u30e9\u30fc\u306b\u306a\u308b\uff1f<\/h1>\n<p>\u4f8b\u3048\u3070\u3001\u6b21\u306e\u3088\u3046\u306a\u30c6\u30fc\u30d6\u30eb\u304c\u3042\u308b\u3068\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"436\" class=\"alignnone size-full wp-image-7009\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/04\/sql_group_by_error_1.png\" alt=\"\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/04\/sql_group_by_error_1.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/04\/sql_group_by_error_1-300x204.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>\u3053\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u306f\u3001\u5404\u30e6\u30fc\u30b6\u30fc\u304c\u6295\u7a3f\u3057\u305f\u5185\u5bb9\u304c\u4fdd\u5b58\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001<strong>\u300c\u30e6\u30fc\u30b6\u30fc\u3054\u3068\u306e\u6700\u65b0\u6295\u7a3f<\/strong><strong>\u300d\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3092\u8003\u3048\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br \/>\n<\/strong>\u304a\u305d\u3089\u304f\u4e00\u756a\u306b\u601d\u3044\u3064\u304f\u306e\u306f\u3053\u3093\u306aSQL\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<pre><strong>SELECT *, MAX(id) FROM posts GROUP BY user_id<\/strong><\/pre>\n<p>\u3057\u304b\u3057\u3001\u6b8b\u5ff5\u306a\u304c\u3089\u3053\u306e\u5834\u5408\u306f\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002\uff08\u6ce8\uff1aMySQL\u306e\u8a2d\u5b9a\u306b\u3082\u3088\u308a\u307e\u3059\uff09<\/p>\n<p>\u3067\u306f\u3001\u6b21\u306e\u5834\u5408\u306f\u3069\u3046\u3067\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>SELECT user_id, MAX(id) FROM posts GROUP BY user_id<\/strong><\/pre>\n<p>\u5b9f\u306f\u3053\u306e\u5834\u5408\u30a8\u30e9\u30fc\u306f\u767a\u751f\u305b\u305a\u6b21\u306e\u3088\u3046\u306a\u7d50\u679c\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7010\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/04\/sql_group_by_error_2.png\" alt=\"\" width=\"326\" height=\"330\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/04\/sql_group_by_error_2.png 326w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/04\/sql_group_by_error_2-296x300.png 296w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/04\/sql_group_by_error_2-100x100.png 100w\" sizes=\"auto, (max-width: 326px) 100vw, 326px\" \/><\/p>\n<p>\u3064\u307e\u308a\u3001\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u305f\u3068\u304d\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u306e\u306f\u6b21\u306e\u5834\u5408\u3067\u3059\u3002<\/p>\n<ul>\n<li><strong>&#8220;GROUP BY&#8221; \u3067\u6307\u5b9a\u3057\u3066\u3044\u306a\u3044\u30ab\u30e9\u30e0<\/strong>\u304c &#8220;SELECT&#8221; \u306b\u5165\u3063\u3066\u3044\u308b<\/li>\n<li>\u305f\u3060\u3057\u3001MAX() \u3084 MIN()\u00a0\u306a\u3069\u306e\u96c6\u8a08\u95a2\u6570\u3092\u4f7f\u3063\u3066\u3044\u308c\u3070\u3069\u306e\u30ab\u30e9\u30e0\u3067\u3082OK<\/li>\n<\/ul>\n<h1>\u306a\u305c\u30a8\u30e9\u30fc\u306b\u306a\u308b\u306e\u304b\uff1f<\/h1>\n<p>\u3056\u3063\u304f\u308a\u8a00\u3046\u3068<code>MySQL<\/code>\u304c\u512a\u67d4\u4e0d\u65ad\u3067\u3001<\/p>\n<p><strong style=\"font-size: 25px;\">\u300c\u3044\u3084\u3044\u3084\u3001\u50d5\u306b\u306f\u3069\u306e\u30c7\u30fc\u30bf\u304b\u6c7a\u3081\u3089\u3093\u306a\u3044\u3088\u30fb\u30fb\u30fb\ud83d\ude2b\u300d<\/strong><\/p>\n<p>\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306e\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br \/>\n\u4f8b\u3048\u3070\u6b21\u306e\u3088\u3046\u306a\u30c6\u30fc\u30d6\u30eb\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7016\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/04\/sql_group_by_error_3.png\" alt=\"\" width=\"640\" height=\"380\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/04\/sql_group_by_error_3.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/04\/sql_group_by_error_3-300x178.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>\u898b\u3066\u3044\u305f\u3060\u304f\u3068\u5206\u304b\u308b\u3068\u304a\u308a\u3001\u30e6\u30fc\u30b6\u30fcID<code>1<\/code>\u306e\u30c7\u30fc\u30bf\u3092<strong><span style=\"color: #ff0000;\">\u8d64<\/span><\/strong>\u3001<code>2<\/code>\u3092<span style=\"color: #008000;\"><strong>\u7dd1<\/strong><\/span>\u3067\u8272\u5206\u3051\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001<code>user_id<\/code>\u3067\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u307e\u3059\u3002<br \/>\n\uff08\u5206\u304b\u308a\u3084\u3059\u304f\u30c7\u30fc\u30bf\u306f<code>id<\/code>\u3001<code>content<\/code>\u3060\u3051\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7018\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/04\/sql_group_by_error_4.png\" alt=\"\" width=\"640\" height=\"329\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/04\/sql_group_by_error_4.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/04\/sql_group_by_error_4-300x154.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>\u3067\u306f\u3001\u3053\u306e\u72b6\u614b\u3067<code>content<\/code>\u3092\u53d6\u5f97\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u3001<code>MySQL<\/code>\u306f\u3069\u3046\u601d\u3046\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7019\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/04\/sql_group_by_error_5.png\" alt=\"\" width=\"640\" height=\"329\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/04\/sql_group_by_error_5.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/04\/sql_group_by_error_5-300x154.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p><strong>\u300c\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u305f\u306e\u306f\u3044\u3044\u3051\u3069\u3001content\u306f\u3044\u3063\u3071\u3044\u3042\u308b\u304b\u3089\u3069\u308c\u3092\u53d6\u3063\u3066\u304f\u308c\u3070\u3044\u3044\u304b\u5206\u304b\u3089\u306a\u3044\u30fb\u30fb\u30fb\ud83d\ude25\u300d<\/strong>\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u304c\u30a8\u30e9\u30fc\u306e\u5168\u8c8c\u3067\u3059\u3002<\/p>\n<p><code>MAX()<\/code>\u3084<code>MIN()<\/code>\u3092\u4f7f\u3046\u3068\u30a8\u30e9\u30fc\u304c\u51fa\u306a\u304f\u306a\u308b\u306e\u3082\u3053\u308c\u304c\u7406\u7531\u3067\u3059\u3002\uff08\u300c\u3069\u308c\uff1f\uff1f\uff1f\u300d\u304c\u306a\u304f\u306a\u308b\u304b\u3089\u3067\u3059\uff09<\/p>\n<h1>\u89e3\u6c7a\u3059\u308b\u306b\u306f<\/h1>\n<p>\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u30c6\u30fc\u30d6\u30eb\u3067\u300c\u30e6\u30fc\u30b6\u30fc\u3054\u3068\u306e\u6700\u65b0\u8a18\u4e8b\u3092\u53d6\u5f97\u3059\u308b\u300d\u305f\u3081\u306b\u306f\u3069\u3046\u3059\u308c\u3070\u3044\u3044\u304b\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7009\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/04\/sql_group_by_error_1.png\" alt=\"\" width=\"640\" height=\"436\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/04\/sql_group_by_error_1.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/04\/sql_group_by_error_1-300x204.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>\u203b\u306a\u304a\u3001\u6700\u5f8c\u306e\u3082\u306e\u4ee5\u5916\u306f\u3001<code>Laravel 7.x<\/code>\u3092\u4f7f\u3063\u305f\u30b3\u30fc\u30c9\u3068\u5b9f\u969b\u306eSQL\u6587\u306e\uff12\u3064\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30b3\u30fc\u30c9\u3092\u5206\u3051\u308b<\/h2>\n<p>\u307e\u305a\u6700\u3082\u30b7\u30f3\u30d7\u30eb\u306a\u306e\u304c\u3001\u30b3\u30fc\u30c9\u3092\u5206\u5272\u3059\u308b\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001<\/p>\n<ol>\n<li>\u30e6\u30fc\u30b6\u30fc\u3054\u3068\u306e\u6700\u65b0ID\u3092\u53d6\u5f97\u3059\u308b<\/li>\n<li>\u305d\u306eID\u3092\u5143\u306bposts\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<\/li>\n<\/ol>\n<p>\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>\/\/ \uff11\uff0e\u30e6\u30fc\u30b6\u30fc\u3054\u3068\u306e\u6700\u65b0ID\u3092\u53d6\u5f97\r\n$ids = \\App\\Post::selectRaw('MAX(id) AS id')\r\n    -&gt;groupBy('user_id')\r\n    -&gt;pluck('id');\r\n\r\n\/\/ \uff12\uff0eID\u3092\u5143\u306b\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\r\n$posts = \\App\\Post::whereIn('id', $ids)<\/strong>\r\n<strong>    -&gt;orderBy('id', 'DESC')<\/strong>\r\n<strong>    -&gt;get();<\/strong><\/pre>\n<p>\u5b9f\u969b\u306eSQL\u6587\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>SELECT MAX(id) AS id FROM posts GROUP BY user_id<\/strong>\r\n\r\n<strong>SELECT * FROM posts WHERE id IN (\uff08\u3053\u3053\u306b\u53d6\u5f97\u3057\u305fID\uff09) ORDER BY id DESC<\/strong><\/pre>\n<h2>WHERE\u53e5\u306b\u30b5\u30d6\u30af\u30a8\u30ea\u3092\u4f7f\u3046<\/h2>\n<p><code>WHERE *** IN<\/code>\u53e5\u306e\u4e2d\u306b\u30b5\u30d6\u30af\u30a8\u30ea\u3092\u4f5c\u3063\u3066\u5b9f\u88c5\u3059\u308b\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n<pre><strong>$posts = \\App\\Post::whereIn('id', function($q) {<\/strong>\r\n\r\n<strong>    \/\/ \ud83d\udc47 \u30b5\u30d6\u30af\u30a8\u30ea<\/strong>\r\n<strong>    return $q-&gt;from('posts')<\/strong>\r\n<strong>        -&gt;selectRaw('MAX(id) as max_id')<\/strong>\r\n<strong>        -&gt;groupBy('user_id');<\/strong>\r\n\r\n<strong>})<\/strong>\r\n<strong>-&gt;orderBy('id', 'DESC')<\/strong>\r\n<strong>-&gt;get();<\/strong><\/pre>\n<p>\u5b9f\u884c\u3055\u308c\u308bSQL\u6587\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>SELECT * FROM posts \r\nWHERE id IN \r\n  (\r\n    SELECT MAX(id) AS max_id FROM posts GROUP BY user_id\r\n  )\r\nORDER BY id DESC<\/strong><\/pre>\n<h2>\u30b5\u30d6\u30af\u30a8\u30ea\u3067\u7d50\u5408\u3059\u308b<\/h2>\n<p>\u3053\u3061\u3089\u3082\u30b5\u30d6\u30af\u30a8\u30ea\u3092\u4f7f\u3044\u307e\u3059\u304c\u3001\u4f7f\u3046\u5834\u6240\u306f<code>INNER JOIN<\/code>\u306e\u4e2d\u3067\u3059\u3002<\/p>\n<pre><strong>$posts = \\App\\Post::join(<\/strong>\r\n<strong>    \\DB::raw('(SELECT MAX(id) AS max_id FROM posts GROUP BY user_id) AS latest'),<\/strong>\r\n<strong>    'posts.id', '=', 'latest.max_id'<\/strong>\r\n<strong>)<\/strong>\r\n<strong>-&gt;orderBy('id', 'DESC')<\/strong>\r\n<strong>-&gt;get();<\/strong><\/pre>\n<p>\u5b9f\u884c\u3055\u308c\u308bSQL\u6587\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>SELECT * FROM posts \r\n  INNER JOIN\r\n  (\r\n    SELECT MAX(id) AS max_id FROM posts GROUP BY user_id\r\n  )\r\n  AS latest \r\n  ON posts.id = latest.max_id \r\nORDER BY id DESC<\/strong><\/pre>\n<h2>only_full_group_by\u3092\u89e3\u9664\u3059\u308b<\/h2>\n<p><code>MySQL<\/code>\u304c\u53b3\u683c\u306a<code>SQL<\/code>\u3092\u8981\u6c42\u3057\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n<code>Laravel<\/code>\u306e\u5834\u5408\u3001<code>config<\/code>\u30d5\u30a1\u30a4\u30eb\u3067\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>\u26a0 \u305f\u3060\u3057\u3001\u3053\u306e\u65b9\u6cd5\u306f\u3042\u307e\u308a\u304a\u3059\u3059\u3081\u3057\u307e\u305b\u3093\u3002<strong>\u884c\u306e\u30c7\u30fc\u30bf\u6574\u5408\u6027\u304c\u304f\u305a\u308c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u304b\u3089\u3067\u3059\u3002<\/strong>\uff08\u4f8b\uff1a<code>id<\/code>\u306f\u6700\u65b0\u306e\u3082\u306e\u306a\u306e\u306b\u3001<code>content<\/code>\u306f\u5225\u306e\u884c\u304b\u3089\u53d6\u5f97\u3055\u308c\u3066\u3057\u307e\u3046\uff09<\/p>\n<p><strong><code>\/config\/database.php<\/code><\/strong><\/p>\n<pre>'mysql' =&gt; [\r\n    'driver' =&gt; 'mysql',\r\n    'url' =&gt; env('DATABASE_URL'),\r\n    'host' =&gt; env('DB_HOST', '127.0.0.1'),\r\n    'port' =&gt; env('DB_PORT', '3306'),\r\n    'database' =&gt; env('DB_DATABASE', 'forge'),\r\n    'username' =&gt; env('DB_USERNAME', 'forge'),\r\n    'password' =&gt; env('DB_PASSWORD', ''),\r\n    'unix_socket' =&gt; env('DB_SOCKET', ''),\r\n    'charset' =&gt; 'utf8mb4',\r\n    'collation' =&gt; 'utf8mb4_unicode_ci',\r\n    'prefix' =&gt; '',\r\n    'prefix_indexes' =&gt; true,\r\n    <strong>'strict' =&gt; false, \/\/ \ud83d\udc48 \u3053\u3053\u3092 \"false\" \u306b\u3059\u308b<\/strong>\r\n    'engine' =&gt; null,\r\n    'options' =&gt; extension_loaded('pdo_mysql') ? array_filter([\r\n        PDO::MYSQL_ATTR_SSL_CA =&gt; env('MYSQL_ATTR_SSL_CA'),\r\n    ]) : [],\r\n],<\/pre>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f<code>MySQL<\/code>\u3067<code>GROUP BY<\/code>\u306e\u30a8\u30e9\u30fc\u306b\u3064\u3044\u3066\u3054\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u306a\u304a\u3001\u305d\u306e\u6614\u306f\u3053\u306e\u3088\u3046\u306a\u554f\u984c\u306f\u767a\u751f\u3057\u3066\u3044\u307e\u305b\u3093\u3067\u3057\u305f\u306e\u3067\u3001\u3082\u3057\u304b\u3059\u308b\u3068<strong><code>MySQL<\/code>\u3092\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3057\u3066\u6025\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u3053\u3068\u304c\u3042\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093<\/strong>\uff08MySQL 5.7\u4ee5\u964d\u3001<code>ONLY_FULL_GROUP_BY<\/code>\u306f\u521d\u671f\u72b6\u614b\u3067\u6709\u52b9\u3067\u3059\uff09<\/p>\n<p>\u305f\u3060\u3001\u3084\u306f\u308a\u65b0\u3057\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u6709\u52b9\u306b\u306a\u3063\u3066\u3044\u308b\u3068\u3044\u3046\u3053\u3068\u306f\u3001\u305d\u3061\u3089\u306e\u65b9\u304c\u3042\u308b\u3079\u304d\u59ff\u3060\u3068\u5224\u65ad\u3055\u308c\u305f\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u306e\u3067\u3001<strong><code>ONLY_FULL_GROUP_BY<\/code>\u306f\u6709\u52b9\u306b\u3057\u3066\u958b\u767a\u3057\u305f\u65b9\u304c\u3044\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/strong><\/p>\n<p>\u305c\u3072\u7686\u3055\u3093\u3082\u4e00\u5ea6\u3053\u306e\u554f\u984c\u3092\u982d\u306e\u4e2d\u3067\u6574\u7406\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\u2757<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3405 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_18.png\" alt=\"\" width=\"310\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_18.png 310w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_18-291x300.png 291w\" sizes=\"auto, (max-width: 310px) 100vw, 310px\" \/><\/p>\n<p style=\"text-align: center;\">\u300c\u4e00\u56de\u3061\u3083\u3093\u3068\u899a\u3048\u3066\u3082\u3001<br \/>\n\u6642\u9593\u304c\u7d4c\u3064\u3068\u5fd8\u308c\u3061\u3083\u3046\u3093\u3067\u3059\u3088\u306d\uff08\u7b11\uff09\u300d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u308c\u306f\u958b\u767a\u8005\u304c\u305f\u307e\u306b\u906d\u9047\u3059\u308b\u300c\u3042\u308b\u3042\u308b\u300d\u306a\u8a71\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001DB\u304b\u3089GROUP BY\u3067\u30c7\u30fc\u30bf\u53d6\u5f97\u3059\u308b\u3068\u304d\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u3053\u3068\u306f\u306a\u3044\u3067\u3057\u3087 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=7001\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;MySQL\u300cGROUP BY\u300d\u30a8\u30e9\u30fc\u89e3\u6c7a\u6cd5\u30fb\u5168\uff14\u4ef6&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":7045,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[215],"tags":[216,60],"class_list":["post-7001","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-215","tag-mysql","tag-60"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/7001","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7001"}],"version-history":[{"count":36,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/7001\/revisions"}],"predecessor-version":[{"id":7079,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/7001\/revisions\/7079"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/7045"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}