{"id":1842,"date":"2025-08-16T10:35:32","date_gmt":"2025-08-16T01:35:32","guid":{"rendered":"https:\/\/route-zero.com\/recruit\/?post_type=route&#038;p=1842"},"modified":"2026-01-16T10:35:44","modified_gmt":"2026-01-16T01:35:44","slug":"sql%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e4%b8%80%e8%a6%a721%e9%81%b8%ef%bd%9c%e3%82%b7%e3%83%bc%e3%83%b3%e5%88%a5%e3%81%a7%e8%bf%b7%e3%82%8f%e3%81%aa%e3%81%84%e4%bd%bf%e3%81%84%e6%96%b9%ef%bc%8b","status":"publish","type":"route","link":"https:\/\/route-zero.com\/recruit\/route\/1842\/","title":{"rendered":"SQL\u30b3\u30de\u30f3\u30c9\u4e00\u89a721\u9078\uff5c\u30b7\u30fc\u30f3\u5225\u3067\u8ff7\u308f\u306a\u3044\u4f7f\u3044\u65b9\uff0b\u30c1\u30fc\u30c8\u30b7\u30fc\u30c8"},"content":{"rendered":"<p><code><\/p>\n<div>\n<h2>\u3010\u30b7\u30fc\u30f3\u5225\u30fb\u30c1\u30fc\u30c8\u30b7\u30fc\u30c8\u4ed8\u3011SQL\u3067\u3088\u304f\u4f7f\u3046\u30b3\u30de\u30f3\u30c921\u9078\uff5c\u3082\u3046\u30b0\u30b0\u3089\u306a\u3044\u305f\u3081\u306e\u5b9f\u8df5\u30ac\u30a4\u30c9<\/h2>\n<h3>\u5c0e\u5165<\/h3>\n<p>\n    \u300c\u307e\u305f<strong>SQL\u30b3\u30de\u30f3\u30c9<\/strong>\u306e\u69cb\u6587\u3092\u30b0\u30b0\u3063\u3066\u3057\u307e\u3063\u305f\u2026\u300d\u300c\u3053\u306e<strong>JOIN<\/strong>\u306e\u66f8\u304d\u65b9\u3067\u672c\u5f53\u306b\u5408\u3063\u3066\u308b\uff1f\u300d<br \/>\n    \u65e5\u3005\u306e\u958b\u767a\u696d\u52d9\u3067SQL\u3092\u4f7f\u3046\u305f\u3073\u3001\u305d\u3093\u306a\u98a8\u306b\u624b\u304c\u6b62\u307e\u308b\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u304b\uff1f<br \/>\n    \u7279\u306bSQL\u306b\u6163\u308c\u3066\u3044\u306a\u3044\u65b9\u306f\u3001\u4f3c\u305f\u3088\u3046\u306a\u30b3\u30de\u30f3\u30c9\u306e\u4f7f\u3044\u5206\u3051\u3084\u8907\u96d1\u306a\u6761\u4ef6\u6307\u5b9a\u306b\u4e0d\u5b89\u3092\u611f\u3058\u304c\u3061\u3067\u3059\u3002<br \/>\n    \u6bce\u56de\u65ad\u7247\u7684\u306b\u8abf\u3079\u308b\u6642\u9593\u306f\u975e\u52b9\u7387\u3067\u3059\u3057\u3001\u5c0f\u3055\u306a\u30df\u30b9\u304c\u30c7\u30fc\u30bf\u306e\u4e0d\u6574\u5408\u306b\u3064\u306a\u304c\u308b\u30ea\u30b9\u30af\u3082\u8003\u3048\u3089\u308c\u307e\u3059\u3002\n  <\/p>\n<p>\n    \u30e2\u30e4\u30e2\u30e4\u3092\u4e00\u7dd2\u306b\u89e3\u6d88\u3057\u307e\u3057\u3087\u3046\u3002\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001\u305d\u3093\u306a\u3042\u306a\u305f\u306e\u305f\u3081\u306e<strong>\u5b9f\u8df5\u7684\u306aSQL\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9<\/strong>\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<br \/>\n    \u5358\u306a\u308b\u30b3\u30de\u30f3\u30c9\u306e\u7f85\u5217\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u300c\u3053\u3046\u3044\u3046\u6642\u3001\u3069\u3046\u66f8\u304f\uff1f\u300d\u3068\u3044\u3046\u5177\u4f53\u7684\u306a\u696d\u52d9\u30b7\u30fc\u30f3\u5225\u306b\u3001\u3059\u3050\u306b\u4f7f\u3048\u308b\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u8c4a\u5bcc\u306b\u63b2\u8f09\u3057\u307e\u3057\u305f\u3002<br \/>\n    <br \/>\n    <strong>JOIN<\/strong\n    >\u306e\u4f7f\u3044\u5206\u3051\u306f\u56f3\u89e3\u3067\u3001<strong>DELETE<\/strong>\u3068<strong>TRUNCATE<\/strong>\u306a\u3069\u9593\u9055\u3044\u3084\u3059\u3044\u30b3\u30de\u30f3\u30c9\u306e\u9055\u3044\u3082\u6bd4\u8f03\u8868\u3067\u5fb9\u5e95\u89e3\u8aac\u3002\u8a18\u4e8b\u306e\u6700\u5f8c\u306b\u306f\u3001\u30b3\u30d4\u30da\u3067\u4f7f\u3048\u308b\u30c1\u30fc\u30c8\u30b7\u30fc\u30c8\u3082\u7528\u610f\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n    <br \/>\n    \u3053\u306e\u8a18\u4e8b\u3092\u8aad\u3081\u3070\u3001SQL\u3092\u8abf\u3079\u308b\u6642\u9593\u304c\u6e1b\u308a\u3001\u81ea\u4fe1\u3092\u6301\u3063\u3066\u30b9\u30d4\u30fc\u30c7\u30a3\u306b\u30b3\u30fc\u30c9\u3092\u66f8\u3051\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\n  <\/p>\n<hr \/>\n<h2>1. SQL\u30b3\u30de\u30f3\u30c9\u306e3\u3064\u306e\u5206\u985e<\/h2>\n<p>\n    SQL\u306e\u30b3\u30de\u30f3\u30c9\u306f\u3001\u305d\u306e\u5f79\u5272\u306b\u3088\u3063\u3066\u5927\u304d\u304f3\u7a2e\u985e\u306b\u5206\u3051\u3089\u308c\u307e\u3059\u3002<br \/>\n    \u307e\u305a\u306f\u3053\u306e\u5168\u4f53\u50cf\u3092\u63b4\u3080\u3053\u3068\u3067\u3001\u3053\u308c\u304b\u3089\u5b66\u3076\u30b3\u30de\u30f3\u30c9\u304c\u3069\u306e\u5f79\u5272\u3092\u6301\u3064\u306e\u304b\u304c\u660e\u78ba\u306b\u306a\u308a\u307e\u3059\u3002\n  <\/p>\n<ul>\n<li><strong>DML (Data Manipulation Language)<\/strong>\uff1a\u30c7\u30fc\u30bf\u3092\u63a2\u3057\u305f\u308a\u3001\u66f8\u304d\u63db\u3048\u305f\u308a\u3059\u308b\u305f\u3081\u306e\u30b3\u30de\u30f3\u30c9\u7fa4\uff08\u4f8b: <strong>SELECT<\/strong>, <strong>INSERT<\/strong>\uff09<\/li>\n<li><strong>DDL (Data Definition Language)<\/strong>\uff1a\u30c6\u30fc\u30d6\u30eb\u305d\u306e\u3082\u306e\u3092\u4f5c\u3063\u305f\u308a\u3001\u69cb\u9020\u3092\u5909\u3048\u305f\u308a\u3059\u308b\u30b3\u30de\u30f3\u30c9\u7fa4\uff08\u4f8b: <strong>CREATE TABLE<\/strong>\uff09<\/li>\n<li><strong>DCL (Data Control Language)<\/strong>\uff1a\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u306e\u30a2\u30af\u30bb\u30b9\u6a29\u9650\u3092\u7ba1\u7406\u3059\u308b\u30b3\u30de\u30f3\u30c9\u7fa4\uff08\u4f8b: <strong>GRANT<\/strong>, <strong>REVOKE<\/strong>\uff09<\/li>\n<\/ul>\n<p>\u672c\u8a18\u4e8b\u3067\u306f\u3001\u30a8\u30f3\u30b8\u30cb\u30a2\u304c\u65e5\u3005\u306e\u696d\u52d9\u3067\u6700\u3082\u983b\u7e41\u306b\u5229\u7528\u3059\u308b<strong>DML<\/strong>\u3092\u4e2d\u5fc3\u306b\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\uff08SQL\u306e\u57fa\u672c\u3084\u5b9f\u884c\u9806\u306b\u3064\u3044\u3066\u306f\u300e<a href=\"https:\/\/route-zero.com\/recruit\/route\/1233\/\">\u521d\u5fc3\u8005\u5411\u3051SQL\u8b1b\u5ea7\uff5cSELECT\u6587\u306e\u66f8\u304d\u65b9\u3068\u5b9f\u884c\u9806\u3092\u5b8c\u5168\u89e3\u8aac<\/a>\u300f\u3092\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\uff09<\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aSQL<\/strong><br \/>\n      \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u5bfe\u3057\u3066\u30c7\u30fc\u30bf\u306e\u691c\u7d22\u30fb\u8ffd\u52a0\u30fb\u66f4\u65b0\u30fb\u524a\u9664\u306a\u3069\u3092\u884c\u3046\u305f\u3081\u306e\u6a19\u6e96\u7684\u306a\u8a00\u8a9e\u3002Structured Query Language\u306e\u7565\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1a\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9<\/strong><br \/>\n      \u30c7\u30fc\u30bf\u3092\u4f53\u7cfb\u7684\u306b\u4fdd\u5b58\u30fb\u7ba1\u7406\u3059\u308b\u30b7\u30b9\u30c6\u30e0\u3002RDB\uff08\u30ea\u30ec\u30fc\u30b7\u30e7\u30ca\u30eb\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\uff09\u304c\u4e3b\u6d41\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aDML\/DDL\/DCL<\/strong><br \/>\n      DML\u306f\u30c7\u30fc\u30bf\u64cd\u4f5c\u3001DDL\u306f\u69cb\u9020\u5b9a\u7fa9\u3001DCL\u306f\u6a29\u9650\u7ba1\u7406\u3092\u62c5\u3046SQL\u30b3\u30de\u30f3\u30c9\u306e\u5206\u985e\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1a\u30c6\u30fc\u30d6\u30eb<\/strong><br \/>\n      \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u5185\u3067\u30c7\u30fc\u30bf\u3092\u884c\u3068\u5217\u3067\u7ba1\u7406\u3059\u308b\u5358\u4f4d\u3002Excel\u306e\u8868\u306e\u3088\u3046\u306a\u30a4\u30e1\u30fc\u30b8\u3002\n    <\/p>\n<\/blockquote>\n<hr \/>\n<h2>2. \u3010\u30b7\u30fc\u30f3\u5225\u3011\u3084\u308a\u305f\u3044\u3053\u3068\u304b\u3089\u63a2\u3059\uff01SQL\u30b3\u30de\u30f3\u30c9\u5b9f\u8df5\u30b5\u30f3\u30d7\u30eb\u96c6<\/h2>\n<p>\n    \u3053\u3053\u3067\u306f\u3001\u5177\u4f53\u7684\u306a\u696d\u52d9\u30b7\u30fc\u30f3\u3092\u60f3\u5b9a\u3057\u305f\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<br \/>\n    \u4ee5\u4e0b\u306e2\u3064\u306e\u30c6\u30fc\u30d6\u30eb\uff08<strong>users<\/strong>\u3068<strong>orders<\/strong>\uff09\u304c\u5b58\u5728\u3059\u308b\u3053\u3068\u3092\u524d\u63d0\u3068\u3057\u3066\u8aad\u307f\u9032\u3081\u3066\u304f\u3060\u3055\u3044\u3002\n  <\/p>\n<ul>\n<li><strong>users<\/strong>\u30c6\u30fc\u30d6\u30eb\uff1a\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u3092\u683c\u7d0d<\/li>\n<li><strong>orders<\/strong>\u30c6\u30fc\u30d6\u30eb\uff1a\u6ce8\u6587\u60c5\u5831\u3092\u683c\u7d0d<\/li>\n<\/ul>\n<h3>(1) \u57fa\u672c\u7684\u306a\u30c7\u30fc\u30bf\u62bd\u51fa\uff1a\u7279\u5b9a\u6761\u4ef6\u306e\u30e6\u30fc\u30b6\u30fc\u3092\u63a2\u3059<\/h3>\n<p><strong>\u30b7\u30fc\u30f3\uff1a\u958b\u767a\u90e8\u9580\u306b\u6240\u5c5e\u3059\u308b\u30e6\u30fc\u30b6\u30fc\u3092\u4e00\u89a7\u8868\u793a\u3057\u305f\u3044<\/strong><\/p>\n<pre><code>SELECT id, name, department\r\nFROM users\r\nWHERE department = '\u958b\u767a';<\/code><\/pre>\n<p><strong>\u30b7\u30fc\u30f3\uff1a\u300c\u9234\u6728\u300d\u3068\u3044\u3046\u59d3\u3092\u6301\u3064\u30e6\u30fc\u30b6\u30fc\u3092\u63a2\u3057\u305f\u3044<\/strong><\/p>\n<pre><code>SELECT id, name\r\nFROM users\r\nWHERE name LIKE '\u9234\u6728%';<\/code><\/pre>\n<h3>(2) \u8907\u6570\u6761\u4ef6\u3067\u306e\u7d5e\u308a\u8fbc\u307f\uff1a\u671f\u9593\u3068\u30b9\u30c6\u30fc\u30bf\u30b9\u3067\u30e6\u30fc\u30b6\u30fc\u3092\u7d5e\u308b<\/h3>\n<p><strong>\u30b7\u30fc\u30f3\uff1a\u958b\u767a\u90e8\u9580\u300c\u307e\u305f\u306f\u300d\u55b6\u696d\u90e8\u9580\u306b\u6240\u5c5e\u3059\u308b\u30e6\u30fc\u30b6\u30fc\u3092\u63a2\u3057\u305f\u3044<\/strong><\/p>\n<pre><code>SELECT id, name, department\r\nFROM users\r\nWHERE department IN ('\u958b\u767a', '\u55b6\u696d');<\/code><\/pre>\n<p><strong>\u30b7\u30fc\u30f3\uff1a2024\u5e741\u6708\u4ee5\u964d\u306b\u767b\u9332\u3057\u305f\u300c\u304b\u3064\u300d\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30e6\u30fc\u30b6\u30fc\u3092\u63a2\u3057\u305f\u3044<\/strong><\/p>\n<pre><code>SELECT id, name, created_at\r\nFROM users\r\nWHERE created_at >= '2024-01-01' AND is_active = true;<\/code><\/pre>\n<h3>(3) \u30c7\u30fc\u30bf\u306e\u7d50\u5408\uff1a\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u3068\u6ce8\u6587\u5c65\u6b74\u3092\u7d10\u4ed8\u3051\u308b<\/h3>\n<p><strong>\u30b7\u30fc\u30f3\uff1a\u6ce8\u6587\u5c65\u6b74\u306e\u3042\u308b\u30e6\u30fc\u30b6\u30fc\u540d\u3068\u305d\u306e\u6ce8\u6587\u5185\u5bb9\u3092\u4e00\u89a7\u8868\u793a\u3057\u305f\u3044<\/strong><\/p>\n<pre><code>SELECT\r\n  u.name,\r\n  o.item_name,\r\n  o.price\r\nFROM users u\r\nINNER JOIN orders o ON u.id = o.user_id;<\/code><\/pre>\n<p>\n    \uff08JOIN\u306e\u57fa\u672c\u3084\u4f7f\u3044\u5206\u3051\u306b\u3064\u3044\u3066\u306f\u300e<a href=\"https:\/\/route-zero.com\/recruit\/route\/1119\/\">SQL JOIN\u306e\u57fa\u672c\u304b\u3089\u5b9f\u8df5\u307e\u3067\uff5cINNER\u30fbLEFT\u30fbRIGHT\u30fbOUTER JOIN\u306e\u9055\u3044\u3092\u308f\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac<\/a>\u300f\u3092\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\uff09\n  <\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aJOIN<\/strong><br \/>\n      \u8907\u6570\u306e\u30c6\u30fc\u30d6\u30eb\u3092\u7279\u5b9a\u306e\u30ad\u30fc\uff08\u4f8b\uff1auser_id\uff09\u3067\u7d50\u5408\u3057\u3001\u95a2\u9023\u3059\u308b\u30c7\u30fc\u30bf\u3092\u307e\u3068\u3081\u3066\u53d6\u5f97\u3059\u308bSQL\u306e\u6a5f\u80fd\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aINNER JOIN \/ LEFT JOIN<\/strong><br \/>\n      INNER JOIN\u306f\u4e21\u65b9\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u8a72\u5f53\u30c7\u30fc\u30bf\u304c\u3042\u308b\u5834\u5408\u306e\u307f\u7d50\u5408\u3001LEFT JOIN\u306f\u5de6\u5074\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u5168\u30c7\u30fc\u30bf\u3092\u6b8b\u3059\u3002\n    <\/p>\n<\/blockquote>\n<h3>(4) \u96c6\u8a08\u3068\u30b0\u30eb\u30fc\u30d4\u30f3\u30b0\uff1a\u90e8\u7f72\u3054\u3068\u306e\u30a2\u30af\u30c6\u30a3\u30d6\u30e6\u30fc\u30b6\u30fc\u6570\u3092\u6570\u3048\u308b<\/h3>\n<p><strong>\u30b7\u30fc\u30f3\uff1a\u90e8\u7f72\u3054\u3068\u306b\u30e6\u30fc\u30b6\u30fc\u304c\u4f55\u4eba\u3044\u308b\u304b\u77e5\u308a\u305f\u3044<\/strong><\/p>\n<pre><code>SELECT department, COUNT(*) AS user_count\r\nFROM users\r\nGROUP BY department;<\/code><\/pre>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aGROUP BY<\/strong><br \/>\n      \u6307\u5b9a\u3057\u305f\u5217\u3054\u3068\u306b\u30c7\u30fc\u30bf\u3092\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u3001\u96c6\u8a08\u95a2\u6570\uff08COUNT, SUM\u306a\u3069\uff09\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u96c6\u8a08\u3059\u308bSQL\u306e\u69cb\u6587\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aCOUNT<\/strong><br \/>\n      \u884c\u6570\u3084\u7279\u5b9a\u5217\u306e\u5024\u306e\u500b\u6570\u3092\u6570\u3048\u308b\u96c6\u8a08\u95a2\u6570\u3002\n    <\/p>\n<\/blockquote>\n<p><strong>\u30b7\u30fc\u30f3\uff1a\u30e6\u30fc\u30b6\u30fc\u6570\u304c3\u4eba\u4ee5\u4e0a\u3044\u308b\u90e8\u7f72\u3060\u3051\u3092\u8868\u793a\u3057\u305f\u3044<\/strong><\/p>\n<pre><code>SELECT department, COUNT(*) AS user_count\r\nFROM users\r\nGROUP BY department\r\nHAVING COUNT(*) >= 3;<\/code><\/pre>\n<h3>(5) \u30c7\u30fc\u30bf\u64cd\u4f5c\uff1a\u30c6\u30b9\u30c8\u30e6\u30fc\u30b6\u30fc\u3092\u4e00\u62ec\u767b\u9332\u30fb\u66f4\u65b0\u30fb\u524a\u9664\u3059\u308b<\/h3>\n<p><strong>\u30b7\u30fc\u30f3\uff1a\u65b0\u3057\u3044\u30e6\u30fc\u30b6\u30fc\u30921\u4ef6\u767b\u9332\u3057\u305f\u3044<\/strong><\/p>\n<pre><code>INSERT INTO users (id, name, department, is_active, created_at)\r\nVALUES (101, '\u30c6\u30b9\u30c8\u30e6\u30fc\u30b6\u30fc', 'QA', true, '2024-05-20');<\/code><\/pre>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aINSERT\/UPDATE\/DELETE<\/strong><br \/>\n      INSERT\u306f\u65b0\u898f\u30c7\u30fc\u30bf\u8ffd\u52a0\u3001UPDATE\u306f\u65e2\u5b58\u30c7\u30fc\u30bf\u306e\u66f4\u65b0\u3001DELETE\u306f\u30c7\u30fc\u30bf\u306e\u524a\u9664\u3092\u884c\u3046SQL\u30b3\u30de\u30f3\u30c9\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aWHERE\u53e5<\/strong><br \/>\n      \u30c7\u30fc\u30bf\u306e\u62bd\u51fa\u3084\u66f4\u65b0\u30fb\u524a\u9664\u306e\u5bfe\u8c61\u3092\u6761\u4ef6\u6307\u5b9a\u3059\u308b\u305f\u3081\u306e\u69cb\u6587\u3002WHERE\u3092\u4ed8\u3051\u5fd8\u308c\u308b\u3068\u5168\u4ef6\u64cd\u4f5c\u306b\u306a\u308b\u305f\u3081\u6ce8\u610f\u3002\n    <\/p>\n<\/blockquote>\n<p><strong>\u30b7\u30fc\u30f3\uff1a\u7279\u5b9a\u306e\u30e6\u30fc\u30b6\u30fc\u306e\u6240\u5c5e\u90e8\u7f72\u3092\u5909\u66f4\u3057\u305f\u3044<\/strong><\/p>\n<pre><code>UPDATE users\r\nSET department = '\u54c1\u8cea\u4fdd\u8a3c'\r\nWHERE id = 101;<\/code><\/pre>\n<p><strong>\u30b7\u30fc\u30f3\uff1a\u4e0d\u8981\u306b\u306a\u3063\u305f\u30c6\u30b9\u30c8\u30e6\u30fc\u30b6\u30fc\u3092\u524a\u9664\u3057\u305f\u3044<\/strong><\/p>\n<pre><code>DELETE FROM users\r\nWHERE name = '\u30c6\u30b9\u30c8\u30e6\u30fc\u30b6\u30fc';<\/code><\/pre>\n<h3>(6) SQL\u306e\u53ef\u8aad\u6027UP\uff1a\u8907\u96d1\u306a\u30af\u30a8\u30ea\u3092\u30b7\u30f3\u30d7\u30eb\u306b\u3059\u308b<\/h3>\n<p><strong>\u30b7\u30fc\u30f3\uff1a\u5404\u90e8\u7f72\u306e\u58f2\u4e0a\u5408\u8a08\u3092\u7b97\u51fa\u3057\u3001\u305d\u306e\u4e2d\u3067\u58f2\u4e0a\u304c10\u4e07\u5186\u4ee5\u4e0a\u306e\u90e8\u7f72\u540d\u3092\u8868\u793a\u3057\u305f\u3044<\/strong><\/p>\n<pre><code>WITH department_sales AS (\r\n  SELECT\r\n    u.department,\r\n    SUM(o.price) AS total_sales\r\n  FROM users u\r\n  JOIN orders o ON u.id = o.user_id\r\n  GROUP BY u.department\r\n)\r\nSELECT department, total_sales\r\nFROM department_sales\r\nWHERE total_sales >= 100000;\r\n<\/code><\/pre>\n<hr \/>\n<h2>3. \u3010\u56f3\u89e3\u3011\u3082\u3046\u8ff7\u308f\u306a\u3044\uff01JOIN\u3068\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u4f7f\u3044\u5206\u3051<\/h2>\n<h3>INNER JOIN vs LEFT JOIN\uff1a\u7d10\u3065\u304f\u30c7\u30fc\u30bf\u304c\u306a\u3044\u6642\u3069\u3046\u306a\u308b\uff1f<\/h3>\n<ul>\n<li><strong>INNER JOIN<\/strong>\uff1a\u4e21\u65b9\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u3001\u7d50\u5408\u30ad\u30fc\uff08<strong>user_id<\/strong>\uff09\u3067\u7d10\u3065\u304f\u30c7\u30fc\u30bf\u304c\u5b58\u5728\u3059\u308b\u5834\u5408\u306e\u307f\u7d50\u679c\u3092\u8fd4\u3057\u307e\u3059\u3002<\/li>\n<li>\n      <strong>LEFT JOIN<\/strong>\uff1a\u5de6\u5074\uff08<strong>users<\/strong>\uff09\u306e\u30c7\u30fc\u30bf\u306f\u3059\u3079\u3066\u8868\u793a\u3002\u53f3\u5074\uff08<strong>orders<\/strong>\uff09\u306b\u7d10\u3065\u304f\u30c7\u30fc\u30bf\u304c\u306a\u304f\u3066\u3082\u3001<strong>NULL<\/strong>\u3068\u3057\u3066\u7d50\u679c\u3092\u8fd4\u3057\u307e\u3059\u3002<br \/>\n      <em>\u300c\u307e\u3060\u4e00\u5ea6\u3082\u6ce8\u6587\u3057\u3066\u3044\u306a\u3044\u30e6\u30fc\u30b6\u30fc\u300d\u3092\u63a2\u3059\u969b\u306b\u3082\u4f7f\u3048\u307e\u3059\u3002<\/em>\n    <\/li>\n<\/ul>\n<h3>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306f\u3069\u3063\u3061\u304c\u826f\u3044\uff1fJOIN\u3068\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u4f7f\u3044\u3069\u3053\u308d<\/h3>\n<ul>\n<li>\u4e00\u822c\u7684\u306b\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30aa\u30d7\u30c6\u30a3\u30de\u30a4\u30b6\u304c\u52b9\u7387\u7684\u306a\u5b9f\u884c\u8a08\u753b\u3092\u7acb\u3066\u3084\u3059\u3044\u305f\u3081\u3001<strong>JOIN<\/strong>\u306e\u65b9\u304c<strong>\u30b5\u30d6\u30af\u30a8\u30ea<\/strong>\u3088\u308a\u3082\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u826f\u3044\u30b1\u30fc\u30b9\u304c\u591a\u3044\u3067\u3059\u3002<\/li>\n<li><strong>JOIN<\/strong>\uff1a\u8907\u6570\u30c6\u30fc\u30d6\u30eb\u306e\u5217\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u30011\u3064\u306e\u5927\u304d\u306a\u7d50\u679c\u30bb\u30c3\u30c8\u3068\u3057\u3066\u6271\u3044\u305f\u3044\u5834\u5408<\/li>\n<li><strong>\u30b5\u30d6\u30af\u30a8\u30ea<\/strong>\uff1a<strong>IN<\/strong>\u53e5\u306e\u6761\u4ef6\u3068\u3057\u3066\u5225\u306e\u30af\u30a8\u30ea\u7d50\u679c\u3092\u4f7f\u3044\u305f\u3044\u5834\u5408\u3084\u3001JOIN\u3067\u306f\u30ed\u30b8\u30c3\u30af\u304c\u8907\u96d1\u306b\u306a\u308a\u3059\u304e\u308b\u5834\u5408<\/li>\n<\/ul>\n<hr \/>\n<h2>4. \u3010\u8981\u6ce8\u610f\u3011\u30c7\u30fc\u30bf\u3092\u58ca\u3055\u306a\u3044\u305f\u3081\u306e\u30b3\u30de\u30f3\u30c9\u6bd4\u8f03\uff1aDELETE, TRUNCATE, DROP<\/h2>\n<p>\n    \u3053\u308c\u3089\u306f\u3059\u3079\u3066\u30c7\u30fc\u30bf\u3092\u300c\u6d88\u3059\u300d\u30b3\u30de\u30f3\u30c9\u3067\u3059\u304c\u3001\u305d\u306e\u5bfe\u8c61\u7bc4\u56f2\u3068\u6319\u52d5\u304c\u5168\u304f\u7570\u306a\u308a\u307e\u3059\u3002<br \/>\n    \u8aa4\u3063\u3066\u4f7f\u3046\u3068\u3001\u5fa9\u65e7\u56f0\u96e3\u306a\u30c7\u30fc\u30bf\u640d\u5931\u306b\u3064\u306a\u304c\u308b\u305f\u3081\u3001\u9055\u3044\u3092\u6b63\u78ba\u306b\u7406\u89e3\u3057\u307e\u3057\u3087\u3046\u3002\n  <\/p>\n<table>\n<thead>\n<tr>\n<th>\u30b3\u30de\u30f3\u30c9<\/th>\n<th>\u5bfe\u8c61\u7bc4\u56f2<\/th>\n<th>\u53d6\u308a\u6d88\u3057\u53ef\u5426<\/th>\n<th>\u901f\u5ea6<\/th>\n<th>\u7279\u5fb4<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>DELETE<\/strong><\/td>\n<td>\u6307\u5b9a\u3057\u305f\u884c\uff08\u30ec\u30b3\u30fc\u30c9\uff09<\/td>\n<td>\u53ef\u80fd\uff08ROLLBACK\uff09<\/td>\n<td>\u9045\u3044<\/td>\n<td>1\u884c\u305a\u3064\u524a\u9664\u51e6\u7406\u3002<code>WHERE<\/code>\u53e5\u3067\u5bfe\u8c61\u3092\u6307\u5b9a\u3067\u304d\u308b\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>TRUNCATE<\/strong><\/td>\n<td>\u30c6\u30fc\u30d6\u30eb\u5185\u306e\u5168\u884c<\/td>\n<td>\u4e0d\u53ef<\/td>\n<td>\u901f\u3044<\/td>\n<td>\u30c6\u30fc\u30d6\u30eb\u81ea\u4f53\u306f\u6b8b\u3057\u3001\u4e2d\u8eab\u3060\u3051\u3092\u9ad8\u901f\u306b\u7a7a\u306b\u3059\u308b\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>DROP<\/strong><\/td>\n<td>\u30c6\u30fc\u30d6\u30eb\u305d\u306e\u3082\u306e<\/td>\n<td>\u4e0d\u53ef<\/td>\n<td>\u901f\u3044<\/td>\n<td>\u30c6\u30fc\u30d6\u30eb\u306e\u69cb\u9020\u3054\u3068\u3001\u30c7\u30fc\u30bf\u3082\u308d\u3068\u3082\u5b8c\u5168\u306b\u524a\u9664\u3059\u308b\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li>\u7279\u5b9a\u306e\u30ec\u30b3\u30fc\u30c9\u3060\u3051\u3092\u6d88\u3057\u305f\u3044\u306a\u3089<strong>DELETE<\/strong><\/li>\n<li>\u30c6\u30fc\u30d6\u30eb\u306e\u30c7\u30fc\u30bf\u3060\u3051\u3092\u5168\u4ef6\u30ea\u30bb\u30c3\u30c8\u3057\u305f\u3044\u306a\u3089<strong>TRUNCATE<\/strong><\/li>\n<li>\u30c6\u30fc\u30d6\u30eb\u81ea\u4f53\u304c\u4e0d\u8981\u306b\u306a\u3063\u305f\u5834\u5408\u306b\u306e\u307f<strong>DROP<\/strong><\/li>\n<li><strong>DELETE<\/strong>\u3084<strong>UPDATE<\/strong>\u3092\u5b9f\u884c\u3059\u308b\u524d\u306f\u3001\u5fc5\u305a<code>SELECT<\/code>\u6587\u3067\u5bfe\u8c61\u30c7\u30fc\u30bf\u3092\u78ba\u8a8d\u3059\u308b<\/li>\n<\/ul>\n<p>\n    \uff08DELETE\u3084TRUNCATE\u3001DROP\u306e\u9055\u3044\u30fb\u6ce8\u610f\u70b9\u306b\u3064\u3044\u3066\u306f\u300e<a href=\"https:\/\/route-zero.com\/recruit\/route\/1779\/\">SQL IN\u30fbEXISTS\u30fbJOIN\u306e\u9055\u3044\u5fb9\u5e95\u89e3\u8aac\uff5c\u5b89\u5168\u3067\u901f\u3044\u9078\u3073\u65b9\u3068\u5b9f\u8df57\u30c1\u30a7\u30c3\u30af<\/a>\u300f\u3082\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\uff09\n  <\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aDELETE\/TRUNCATE\/DROP<\/strong><br \/>\n      DELETE\u306f\u884c\u5358\u4f4d\u524a\u9664\uff08\u5143\u306b\u623b\u305b\u308b\uff09\u3001TRUNCATE\u306f\u30c6\u30fc\u30d6\u30eb\u5168\u884c\u524a\u9664\uff08\u5143\u306b\u623b\u305b\u306a\u3044\uff09\u3001DROP\u306f\u30c6\u30fc\u30d6\u30eb\u81ea\u4f53\u3092\u524a\u9664\uff08\u5143\u306b\u623b\u305b\u306a\u3044\uff09\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aROLLBACK<\/strong><br \/>\n      \u76f4\u524d\u306e\u64cd\u4f5c\u3092\u53d6\u308a\u6d88\u3057\u3066\u5143\u306b\u623b\u3059\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u6a5f\u80fd\u3002TRUNCATE\u3084DROP\u306f\u57fa\u672c\u7684\u306bROLLBACK\u4e0d\u53ef\u3002\n    <\/p>\n<\/blockquote>\n<hr \/>\n<h2>5. \u30b3\u30d4\u30da\u3067\u5373\u6226\u529b\uff01SQL\u30b3\u30de\u30f3\u30c9\u30c1\u30fc\u30c8\u30b7\u30fc\u30c8<\/h2>\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u7d39\u4ecb\u3057\u305f\u5b9f\u8df5\u7684\u306a\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u307e\u3068\u3081\u307e\u3057\u305f\u3002\u65e5\u3005\u306e\u696d\u52d9\u3067\u300c\u3042\u306e\u66f8\u304d\u65b9\u3001\u3069\u3046\u3060\u3063\u3051\uff1f\u300d\u3068\u306a\u3063\u305f\u6642\u306b\u3001\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3092\u30b3\u30d4\u30fc\u3057\u3066\u3054\u6d3b\u7528\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><code>SELECT id, name FROM users WHERE department = '\u958b\u767a';\r\nSELECT id, name FROM users WHERE department IN ('\u958b\u767a', '\u55b6\u696d');\r\nSELECT u.name, o.item_name FROM users u JOIN orders o ON u.id = o.user_id;\r\nSELECT department, COUNT(*) FROM users GROUP BY department;\r\nSELECT department, COUNT(*) FROM users GROUP BY department HAVING COUNT(*) >= 3;\r\nINSERT INTO users (id, name, department) VALUES (101, '\u65b0\u898f\u30e6\u30fc\u30b6\u30fc', 'QA');\r\nUPDATE users SET department = '\u54c1\u8cea\u4fdd\u8a3c' WHERE id = 101;\r\nDELETE FROM users WHERE id = 101;\r\n<\/code><\/pre>\n<hr \/>\n<h2>6. FAQ\u30bb\u30af\u30b7\u30e7\u30f3<\/h2>\n<ol>\n<li>\n      <strong>Q1. <strong>WHERE<\/strong>\u53e5\u3067<strong>NULL<\/strong>\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u62bd\u51fa\u3059\u308b\u306b\u306f\uff1f<\/strong><\/p>\n<pre><code>SELECT * FROM users WHERE department IS NULL;\r\n<\/code><\/pre>\n<blockquote>\n<p>\n          <strong>\u7528\u8a9e\u89e3\u8aac\uff1aNULL<\/strong><br \/>\n          \u30c7\u30fc\u30bf\u304c\u672a\u5165\u529b\u30fb\u672a\u8a2d\u5b9a\u3067\u3042\u308b\u3053\u3068\u3092\u793a\u3059\u7279\u5225\u306a\u5024\u30020\u3084\u7a7a\u6587\u5b57\u3068\u306f\u7570\u306a\u308b\u3002\n        <\/p>\n<\/blockquote>\n<\/li>\n<li>\n      <strong>Q2. <strong>UNION<\/strong>\u3068<strong>UNION ALL<\/strong>\u306e\u9055\u3044\u306f\uff1f<\/strong><\/p>\n<ul>\n<li><strong>UNION<\/strong>\uff1a\u91cd\u8907\u3059\u308b\u884c\u3092\u81ea\u52d5\u7684\u306b\u6392\u9664<\/li>\n<li><strong>UNION ALL<\/strong>\uff1a\u91cd\u8907\u3092\u6c17\u306b\u305b\u305a\u5168\u3066\u306e\u7d50\u679c\u3092\u8fd4\u3059\uff08\u4e00\u822c\u7684\u306b\u9ad8\u901f\uff09<\/li>\n<\/ul>\n<\/li>\n<li>\n      <strong>Q3. SQL\u30b3\u30de\u30f3\u30c9\u3067\u5927\u6587\u5b57\u3068\u5c0f\u6587\u5b57\u306f\u533a\u5225\u3055\u308c\u308b\uff1f<\/strong><br \/>\n      <span>\u30b3\u30de\u30f3\u30c9\u81ea\u4f53\u306f\u533a\u5225\u3057\u306a\u3044DB\u304c\u591a\u3044\u304c\u3001\u30c7\u30fc\u30bf\u306e\u533a\u5225\u306f\u7167\u5408\u9806\u5e8f\u6b21\u7b2c<\/span>\n    <\/li>\n<li>\n      <strong>Q4. <strong>COUNT(*)<\/strong>\u3068<strong>COUNT(\u5217\u540d)<\/strong>\u306e\u9055\u3044\u306f\uff1f<\/strong><\/p>\n<ul>\n<li><strong>COUNT(*)<\/strong>\uff1a<strong>NULL<\/strong>\u542b\u3080\u5168\u884c\u6570<\/li>\n<li><strong>COUNT(\u5217\u540d)<\/strong>\uff1a<strong>NULL<\/strong>\u3067\u306a\u3044\u884c\u306e\u307f<\/li>\n<\/ul>\n<\/li>\n<li>\n      <strong>Q5. SQL\u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u5bfe\u7b56\u306f\uff1f<\/strong><br \/>\n      <span>\u30e6\u30fc\u30b6\u30fc\u5165\u529b\u306f\u76f4\u63a5\u7d50\u5408\u305b\u305a\u3001<strong>\u30d7\u30ec\u30fc\u30b9\u30db\u30eb\u30c0\uff08\u30d0\u30a4\u30f3\u30c9\u5909\u6570\uff09<\/strong>\u3092\u4f7f\u3046<\/span>\n    <\/li>\n<\/ol>\n<hr \/>\n<h2>7. \u307e\u3068\u3081<\/h2>\n<p>\u672c\u8a18\u4e8b\u3067\u306f\u3001SQL\u306b\u6163\u308c\u3066\u3044\u306a\u3044\u65b9\u304c\u5b9f\u52d9\u3067\u983b\u7e41\u306b\u906d\u9047\u3059\u308b\u30b7\u30fc\u30f3\u5225\u306b\u3001\u3088\u304f\u4f7f\u3046SQL\u30b3\u30de\u30f3\u30c9\u3092\u89e3\u8aac\u3057\u307e\u3057\u305f\u3002<\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1a\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9<\/strong><br \/>\n      \u5b9f\u52d9\u3067\u56f0\u3063\u305f\u3068\u304d\u306b\u3059\u3050\u53c2\u7167\u3067\u304d\u308b\u300c\u9006\u5f15\u304d\u8f9e\u5178\u300d\u7684\u306a\u8cc7\u6599\u3084\u8a18\u4e8b\u306e\u3053\u3068\u3002\n    <\/p>\n<\/blockquote>\n<ul>\n<li>SQL\u30b3\u30de\u30f3\u30c9\u306f<strong>DML, DDL, DCL<\/strong>\u306e3\u3064\u306b\u5927\u5225\u3055\u308c\u308b<\/li>\n<li>\u300c\u3084\u308a\u305f\u3044\u3053\u3068\u300d\u304b\u3089\u9006\u5f15\u304d\u3067\u304d\u308b\u5b9f\u8df5\u7684\u306a\u30b5\u30f3\u30d7\u30eb\u304c\u958b\u767a\u52b9\u7387\u3092\u4e0a\u3052\u308b<\/li>\n<li><strong>JOIN<\/strong>\u3084<strong>DELETE\/TRUNCATE<\/strong>\u306a\u3069\u3001\u3064\u307e\u305a\u304d\u3084\u3059\u3044\u30b3\u30de\u30f3\u30c9\u306f\u9055\u3044\u3092\u6b63\u78ba\u306b\u7406\u89e3\u3059\u308b\u3053\u3068\u304c\u91cd\u8981<\/li>\n<\/ul>\n<p>\n    \u6700\u521d\u306f\u899a\u3048\u308b\u3053\u3068\u304c\u591a\u304f\u5927\u5909\u306b\u611f\u3058\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u30b3\u30de\u30f3\u30c9\u306e\u5f79\u5272\u3068\u5177\u4f53\u7684\u306a\u5229\u7528\u30b7\u30fc\u30f3\u3092\u7d50\u3073\u3064\u3051\u3066\u3044\u304f\u3053\u3068\u3067\u3001\u77e5\u8b58\u306f\u7740\u5b9f\u306b\u5b9a\u7740\u3057\u307e\u3059\u3002 <br \/>\u305c\u3072\u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30da\u3057\u3066\u3001\u307e\u305a\u306f\u52d5\u304b\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002\n  <\/p>\n<hr \/>\n<\/div>\n","protected":false},"featured_media":1843,"template":"","_links":{"self":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/route\/1842"}],"collection":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/route"}],"about":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/types\/route"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/media\/1843"}],"wp:attachment":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/media?parent=1842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}