{"id":18453,"date":"2026-07-19T06:44:59","date_gmt":"2026-07-18T21:44:59","guid":{"rendered":"https:\/\/genai-ai.co.jp\/ai-kanri\/?p=18453"},"modified":"2026-07-19T06:44:59","modified_gmt":"2026-07-18T21:44:59","slug":"cc-sql-in-clause","status":"publish","type":"post","link":"https:\/\/genai-ai.co.jp\/ai-kanri\/blog\/cc-sql-in-clause\/","title":{"rendered":"\u30102026\u5e747\u6708\u6700\u65b0\u3011SQL IN\u53e5\u5b8c\u5168\u30ac\u30a4\u30c9\uff5c\u57fa\u672c\u30fbNOT IN\u30fb\u30b5\u30d6\u30af\u30a8\u30ea\u30fbEXISTS\u3068\u306e\u6bd4\u8f03\u30fbClaude Code\u6d3b\u7528"},"content":{"rendered":"\n<style>\n.g-flow-row{display:flex;gap:8px;justify-content:center;flex-wrap:wrap;align-items:center;}\n.g-flow-item{background:linear-gradient(135deg,#1a1a1a,#2a1015);color:#fff;border-radius:8px;padding:16px 14px;min-width:130px;flex:1;text-align:center;}\n.g-flow-arrow{color:#dc2626;font-size:20px;font-weight:700;}\n.g-card-row{display:flex;gap:12px;flex-wrap:wrap;margin:0 0 32px;}\n.g-card-row>div{flex:1;min-width:220px;}\n@media(max-width:600px){\n  .g-flow-row{flex-direction:column;}\n  .g-flow-arrow{transform:rotate(90deg);}\n  .g-card-row{flex-direction:column;}\n  .g-card-row>div{min-width:100%;}\n}\n<\/style>\n\n\n\n<div style=\"margin:0 0 32px;\">\n  <img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/07\/thumb-cc-sql-in-clause.jpg\" alt=\"\u30102026\u5e747\u6708\u6700\u65b0\u3011SQL IN\u53e5\u5b8c\u5168\u30ac\u30a4\u30c9\uff5c\u57fa\u672c\u30fbNOT IN\u30fb\u30b5\u30d6\u30af\u30a8\u30ea\u30fbEXISTS\u3068\u306e\u6bd4\u8f03\u30fbClaude Code\u6d3b\u7528\" style=\"width:100%;height:auto;border-radius:12px;display:block;\">\n<\/div>\n\n\n\n<div style=\"background:#f8f9fa;border-radius:12px;padding:24px 28px;margin:0 0 32px;border-left:4px solid #0ea5e9;\">\n  <p style=\"font-size:15px;font-weight:700;color:#1a1a1a;margin:0 0 16px;\">\u3053\u306e\u8a18\u4e8b\u306e\u5185\u5bb9<\/p>\n  <ol style=\"margin:0;padding-left:20px;font-size:14px;line-height:2.2;list-style:none;\">\n    <li><a href=\"#sec-01\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#0ea5e9;font-weight:700;margin-right:8px;\">01<\/span>SQL IN\u53e5\u306e\u57fa\u672c\u69cb\u6587\u3068\u4f7f\u3044\u65b9<\/a><\/li>\n    <li><a href=\"#sec-02\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#0ea5e9;font-weight:700;margin-right:8px;\">02<\/span>IN\u53e5 vs OR\u6f14\u7b97\u5b50\u306e\u9055\u3044\u3068\u3069\u3061\u3089\u3092\u4f7f\u3046\u3079\u304d\u304b<\/a><\/li>\n    <li><a href=\"#sec-03\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#0ea5e9;font-weight:700;margin-right:8px;\">03<\/span>NOT IN\u53e5\u306e\u4f7f\u3044\u65b9\u3068\u6ce8\u610f\u70b9<\/a><\/li>\n    <li><a href=\"#sec-04\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#0ea5e9;font-weight:700;margin-right:8px;\">04<\/span>IN\u53e5\u3068\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u7d44\u307f\u5408\u308f\u305b<\/a><\/li>\n    <li><a href=\"#sec-05\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#0ea5e9;font-weight:700;margin-right:8px;\">05<\/span>IN vs EXISTS\uff1a\u3069\u3061\u3089\u3092\u9078\u3076\u3079\u304d\u304b<\/a><\/li>\n    <li><a href=\"#sec-06\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#0ea5e9;font-weight:700;margin-right:8px;\">06<\/span>IN\u53e5\u306bNULL\u304c\u542b\u307e\u308c\u308b\u5834\u5408\u306e\u843d\u3068\u3057\u7a74<\/a><\/li>\n    <li><a href=\"#sec-07\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#0ea5e9;font-weight:700;margin-right:8px;\">07<\/span>IN\u53e5\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u6700\u9069\u5316<\/a><\/li>\n    <li><a href=\"#sec-08\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#0ea5e9;font-weight:700;margin-right:8px;\">08<\/span>Claude Code\u3067SQL IN\u53e5\u30af\u30a8\u30ea\u3092\u81ea\u52d5\u751f\u6210\u3059\u308b<\/a><\/li>\n    <li><a href=\"#faq\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#0ea5e9;font-weight:700;margin-right:8px;\">FAQ<\/span>\u3088\u304f\u3042\u308b\u8cea\u554f<\/a><\/li>\n  <\/ol>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">SQL\u3067\u30c7\u30fc\u30bf\u3092\u691c\u7d22\u3059\u308b\u3068\u304d\u300c\u3053\u306e3\u3064\u306e\u90fd\u5e02\u306e\u9867\u5ba2\u3092\u53d6\u5f97\u3057\u305f\u3044\u300d\u300c\u3053\u306e\u5546\u54c1\u30b3\u30fc\u30c9\u306e\u4e00\u89a7\u306b\u542b\u307e\u308c\u308b\u6ce8\u6587\u3092\u62bd\u51fa\u3057\u305f\u3044\u300d\u3068\u3044\u3046\u5834\u9762\u3067\u4f7f\u3046\u306e\u304c<strong>IN\u53e5<\/strong>\u3067\u3059\u3002OR\u3092\u8907\u6570\u4e26\u3079\u308b\u3088\u308a\u7c21\u6f54\u306b\u66f8\u3051\u3001\u30b5\u30d6\u30af\u30a8\u30ea\u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u5f37\u529b\u306a\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u304c\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001IN\u53e5\u306e\u57fa\u672c\u69cb\u6587\u304b\u3089\u3001NOT IN\u30fb\u30b5\u30d6\u30af\u30a8\u30ea\u3068\u306e\u7d44\u307f\u5408\u308f\u305b\u30fbEXISTS\u3068\u306e\u9055\u3044\u30fbNULL\u304c\u542b\u307e\u308c\u308b\u5834\u5408\u306e\u843d\u3068\u3057\u7a74\u30fb\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u8003\u3048\u65b9\u30fbClaude Code\u306b\u3088\u308bSQL\u81ea\u52d5\u751f\u6210\u307e\u3067\u3001\u5b9f\u8df5\u30b3\u30fc\u30c9\u3068\u3068\u3082\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"balloon-wrap\">\n  <div class=\"balloon-icon\">\n    <img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/04\/ceo-sugasawa.jpg\" alt=\"\u4ee3\u8868\u83c5\u6fa4\">\n    <span class=\"balloon-name\">\u4ee3\u8868\u83c5\u6fa4<\/span>\n  <\/div>\n  <div class=\"balloon-body\">IN\u53e5\u306f\u300c\u8907\u6570\u306e\u5024\u306e\u4e2d\u306b\u542b\u307e\u308c\u308b\u304b\u3092\u78ba\u8a8d\u3059\u308b\u300d\u6f14\u7b97\u5b50\u3067\u3059\u3002\u4f7f\u3044\u65b9\u306f\u5358\u7d14\u3067\u3059\u304c\u3001NULL\u3068NOT IN\u306e\u7d44\u307f\u5408\u308f\u305b\u3001\u5927\u91cf\u30c7\u30fc\u30bf\u3067\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3001EXISTS\u3068\u306e\u4f7f\u3044\u5206\u3051\u306a\u3069\u3001\u77e5\u3089\u306a\u3044\u3068\u672c\u756a\u3067\u554f\u984c\u306b\u306a\u308b\u843d\u3068\u3057\u7a74\u304c\u3042\u308a\u307e\u3059\u3002\u4eca\u65e5\u306f\u305d\u3053\u307e\u3067\u8e0f\u307f\u8fbc\u3093\u3067\u89e3\u8aac\u3057\u307e\u3059\u3002<\/div>\n<\/div>\n\n\n\n<div style=\"background:#fafafa;border-radius:8px;padding:16px 20px;margin:16px 0;border-left:4px solid #dc2626;\">\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span>IN\u53e5\u306e<strong>\u57fa\u672c\u69cb\u6587<\/strong>\uff08WHERE column IN (\u50241, \u50242, \u50243)\uff09<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span>IN\u53e5 vs OR\u6f14\u7b97\u5b50\uff1a<strong>\u3069\u3061\u3089\u3092\u4f7f\u3046\u3079\u304d\u304b<\/strong>\u306e\u5224\u65ad\u57fa\u6e96<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>NOT IN<\/strong>\u306e\u4f7f\u3044\u65b9\u3068<strong>NULL\u304c\u6df7\u5728\u3059\u308b\u3068\u5168\u884c\u30bc\u30ed\u306b\u306a\u308b\u7f60<\/strong><\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span>IN\u53e5\u3068<strong>\u30b5\u30d6\u30af\u30a8\u30ea<\/strong>\uff08SELECT\u6587\uff09\u306e\u7d44\u307f\u5408\u308f\u305b\u30d1\u30bf\u30fc\u30f3<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>IN vs EXISTS<\/strong>\uff1a\u5b9f\u884c\u8a08\u753b\u30fb\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u9055\u3044\u3068\u9078\u3073\u65b9<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span>IN\u53e5\u306e\u30ea\u30b9\u30c8\u304c\u9577\u304f\u306a\u308b\u5834\u5408\u306e<strong>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5bfe\u7b56<\/strong><\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>Claude Code<\/strong>\u3067SQL IN\u53e5\u30af\u30a8\u30ea\u3092\u81ea\u52d5\u751f\u6210\u3059\u308b\u65b9\u6cd5<\/span><\/div>\n\n<\/div>\n\n\n\n<div id=\"sec-01\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">01<\/span>\n  <span class=\"section-label\" style=\"display:block;\">BASIC<\/span>\n  <span class=\"section-title\" style=\"display:block;\">SQL IN\u53e5\u306e\u57fa\u672c\u69cb\u6587\u3068\u4f7f\u3044\u65b9<\/span>\n  <span class=\"section-desc\">WHERE col IN (\u5024\u30ea\u30b9\u30c8)\u306e\u57fa\u672c\u5f62\u3068\u30c7\u30fc\u30bf\u578b\u5225\u306e\u4f7f\u3044\u65b9<\/span>\n<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">IN\u53e5\u306fWHERE\u53e5\u306e\u4e2d\u3067\u4f7f\u3044\u3001<strong>\u6307\u5b9a\u3057\u305f\u5024\u306e\u30ea\u30b9\u30c8\u306e\u3044\u305a\u308c\u304b\u306b\u4e00\u81f4\u3059\u308b\u884c<\/strong>\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;color:#d4d4d4;font-size:13px;line-height:1.8;font-family:'Consolas','Courier New',monospace;white-space:pre;\">-- IN\u53e5\u306e\u57fa\u672c\u69cb\u6587\nSELECT \u30ab\u30e9\u30e0\u540d\nFROM \u30c6\u30fc\u30d6\u30eb\u540d\nWHERE \u30ab\u30e9\u30e0\u540d IN (\u50241, \u50242, \u50243, ...);\n\n-- \u6570\u5024\u578b\u306eIN\u53e5\nSELECT *\nFROM orders\nWHERE status_id IN (1, 2, 5);\n-- status_id\u304c1\u30fb2\u30fb5\u306e\u3044\u305a\u308c\u304b\u306e\u6ce8\u6587\u3092\u53d6\u5f97\n\n-- \u6587\u5b57\u5217\u578b\u306eIN\u53e5\uff08\u30b7\u30f3\u30b0\u30eb\u30af\u30a9\u30fc\u30c8\u3067\u56f2\u3080\uff09\nSELECT *\nFROM customers\nWHERE prefecture IN ('\u6771\u4eac\u90fd', '\u5927\u962a\u5e9c', '\u795e\u5948\u5ddd\u770c');\n-- 3\u90fd\u5e9c\u770c\u306e\u9867\u5ba2\u3092\u53d6\u5f97\n\n-- \u65e5\u4ed8\u578b\u306eIN\u53e5\nSELECT *\nFROM sales\nWHERE sale_date IN ('2026-07-01', '2026-07-15', '2026-07-19');\n\n-- \u8907\u6570\u30ab\u30e9\u30e0\u306e\u6761\u4ef6\u3068\u7d44\u307f\u5408\u308f\u305b\nSELECT order_id, customer_name, total_amount\nFROM orders\nWHERE status_id IN (1, 2)\n  AND total_amount >= 10000;\n-- \u30b9\u30c6\u30fc\u30bf\u30b9\u304c1\u304b2\u3067\u3001\u91d1\u984d1\u4e07\u4ee5\u4e0a\u306e\u6ce8\u6587<\/pre>\n<\/div>\n\n\n\n<div style=\"background:#f8f9fa;border-left:4px solid #6b7280;border-radius:0 8px 8px 0;padding:16px 20px;margin:20px 0;\">\n  <p style=\"margin:0 0 4px;font-size:13px;font-weight:700;color:#6b7280;letter-spacing:1px;\">&#128218; \u7528\u8a9e\u89e3\u8aac<\/p>\n  <p style=\"margin:0;font-size:15px;line-height:1.7;\"><strong>IN\u53e5\u306e\u8a55\u4fa1\u65b9\u6cd5<\/strong>\uff1aWHERE col IN (v1, v2, v3) \u306f\u5185\u90e8\u7684\u306bcol = v1 OR col = v2 OR col = v3\u3068\u540c\u7b49\u306b\u8a55\u4fa1\u3055\u308c\u308b\u3002\u305f\u3060\u3057IN\u306e\u30ea\u30b9\u30c8\u306f\u53ef\u8aad\u6027\u304c\u9ad8\u304f\u3001\u6700\u9069\u5316\u30a8\u30f3\u30b8\u30f3\u304c\u52b9\u7387\u7684\u306a\u5b9f\u884c\u8a08\u753b\u3092\u9078\u629e\u3057\u3084\u3059\u3044\u3002IN\u53e5\u306e\u30ea\u30b9\u30c8\u306f\u30b3\u30f3\u30de\u533a\u5207\u308a\u306e\u5024\u306e\u96c6\u5408\u3067\u3042\u308a\u3001\u91cd\u8907\u3057\u305f\u5024\u306f1\u3064\u3068\u3057\u3066\u6271\u308f\u308c\u308b\uff08SELECT * FROM t WHERE x IN (1, 1, 2) \u306f x IN (1, 2) \u3068\u540c\u3058\uff09\u3002<\/p>\n<\/div>\n\n\n\n<table>\n<thead><tr><th>\u30c7\u30fc\u30bf\u578b<\/th><th>\u8a18\u8ff0\u4f8b<\/th><th>\u6ce8\u610f\u70b9<\/th><\/tr><\/thead>\n<tbody>\n<tr><td>\u6570\u5024\uff08INT\uff09<\/td><td>WHERE id IN (1, 2, 3)<\/td><td>\u30af\u30a9\u30fc\u30c8\u4e0d\u8981<\/td><\/tr>\n<tr><td>\u6587\u5b57\u5217\uff08VARCHAR\uff09<\/td><td>WHERE name IN ('\u7530\u4e2d', '\u5c71\u7530')<\/td><td>\u30b7\u30f3\u30b0\u30eb\u30af\u30a9\u30fc\u30c8\u3067\u56f2\u3080<\/td><\/tr>\n<tr><td>\u65e5\u4ed8\uff08DATE\uff09<\/td><td>WHERE dt IN ('2026-01-01', '2026-01-15')<\/td><td>ISO\u5f62\u5f0fYYYY-MM-DD\u63a8\u5968<\/td><\/tr>\n<tr><td>BOOLEAN<\/td><td>WHERE active IN (TRUE, FALSE)<\/td><td>DB\u306b\u3088\u3063\u3066\u8a18\u8ff0\u304c\u7570\u306a\u308b<\/td><\/tr>\n<\/tbody>\n<\/table>\n\n\n\n<div id=\"sec-02\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">02<\/span>\n  <span class=\"section-label\" style=\"display:block;\">IN_VS_OR<\/span>\n  <span class=\"section-title\" style=\"display:block;\">IN\u53e5 vs OR\u6f14\u7b97\u5b50\u306e\u9055\u3044\u3068\u3069\u3061\u3089\u3092\u4f7f\u3046\u3079\u304d\u304b<\/span>\n  <span class=\"section-desc\">\u53ef\u8aad\u6027\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u89b3\u70b9\u304b\u3089\u306e\u4f7f\u3044\u5206\u3051<\/span>\n<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">IN\u53e5\u3068OR\u6f14\u7b97\u5b50\u306f\u540c\u3058\u7d50\u679c\u3092\u8fd4\u3057\u307e\u3059\u304c\u3001<strong>\u53ef\u8aad\u6027\u3068\u4fdd\u5b88\u6027\u306e\u89b3\u70b9\u304b\u3089IN\u53e5\u304c\u63a8\u5968<\/strong>\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;color:#d4d4d4;font-size:13px;line-height:1.8;font-family:'Consolas','Courier New',monospace;white-space:pre;\">-- OR\u6f14\u7b97\u5b50\u3067\u66f8\u304f\u5834\u5408\uff08\u5024\u304c\u5897\u3048\u308b\u3068\u8aad\u307f\u306b\u304f\u3044\uff09\nSELECT *\nFROM orders\nWHERE status_id = 1\n   OR status_id = 2\n   OR status_id = 5\n   OR status_id = 8\n   OR status_id = 10;\n\n-- IN\u53e5\u3067\u66f8\u304f\u5834\u5408\uff08\u3059\u3063\u304d\u308a\u3068\u8aad\u307f\u3084\u3059\u3044\uff09\nSELECT *\nFROM orders\nWHERE status_id IN (1, 2, 5, 8, 10);\n\n-- \u7d50\u679c\u306f\u5b8c\u5168\u306b\u540c\u3058\n-- IN\u53e5\u306e\u307b\u3046\u304c\uff1a\n-- \u2460 \u66f8\u304f\u91cf\u304c\u5c11\u306a\u3044\n-- \u2461 \u5024\u306e\u8ffd\u52a0\u30fb\u524a\u9664\u304c\u7c21\u5358\n-- \u2462 \u30b3\u30fc\u30c9\u30ec\u30d3\u30e5\u30fc\u3067\u610f\u56f3\u304c\u4f1d\u308f\u308a\u3084\u3059\u3044<\/pre>\n<\/div>\n\n\n\n<div style=\"background:#f0fdf4;border:1px solid #22c55e;border-radius:8px;padding:20px 24px;margin:24px 0;\">\n  <div style=\"display:flex;align-items:center;gap:8px;margin-bottom:12px;\">\n    <span style=\"font-size:18px;\">&#128161;<\/span>\n    <strong style=\"color:#16a34a;font-size:15px;\">IN\u53e5\u3068OR\u306f\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u307b\u307c\u540c\u3058<\/strong>\n  <\/div>\n  <p style=\"margin:0;font-size:15px;line-height:1.8;color:#333;\">\u30e2\u30c0\u30f3\u306aRDBMS\uff08MySQL, PostgreSQL, SQL Server\u7b49\uff09\u3067\u306f\u3001IN\u53e5\u3068OR\u306f\u30af\u30a8\u30ea\u30aa\u30d7\u30c6\u30a3\u30de\u30a4\u30b6\u306b\u3088\u3063\u3066\u540c\u7b49\u306e\u5b9f\u884c\u8a08\u753b\u306b\u5909\u63db\u3055\u308c\u307e\u3059\u3002\u304b\u3064\u3066\u306f\u300cIN\u53e5\u306fOR\u3088\u308a\u9045\u3044\u300d\u3068\u3044\u3046\u8aac\u3082\u3042\u308a\u307e\u3057\u305f\u304c\u3001\u73fe\u5728\u306eDB\u3067\u306f\u307b\u307c\u540c\u7b49\u3067\u3059\u3002\u5024\u304c3\u3064\u4ee5\u4e0a\u306b\u306a\u308b\u5834\u5408\u306f\u53ef\u8aad\u6027\u306e\u89b3\u70b9\u304b\u3089IN\u53e5\u3092\u4f7f\u3046\u306e\u304c\u63a8\u5968\u3067\u3059\u3002<\/p>\n<\/div>\n\n\n\n<div id=\"sec-03\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">03<\/span>\n  <span class=\"section-label\" style=\"display:block;\">NOT_IN<\/span>\n  <span class=\"section-title\" style=\"display:block;\">NOT IN\u53e5\u306e\u4f7f\u3044\u65b9\u3068\u6ce8\u610f\u70b9<\/span>\n  <span class=\"section-desc\">NOT IN\u306fNULL\u304c\u542b\u307e\u308c\u308b\u3068\u7d50\u679c\u304c\u5168\u4ef6\u30bc\u30ed\u306b\u306a\u308b\u91cd\u5927\u306a\u843d\u3068\u3057\u7a74<\/span>\n<\/h2>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;color:#d4d4d4;font-size:13px;line-height:1.8;font-family:'Consolas','Courier New',monospace;white-space:pre;\">-- NOT IN\u53e5\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\n-- \u300c\u30ea\u30b9\u30c8\u306b\u542b\u307e\u308c\u306a\u3044\u884c\u3092\u53d6\u5f97\u3059\u308b\u300d\nSELECT *\nFROM orders\nWHERE status_id NOT IN (3, 4, 9);\n-- \u30b9\u30c6\u30fc\u30bf\u30b9\u304c3\u30fb4\u30fb9\u4ee5\u5916\u306e\u6ce8\u6587\u3092\u53d6\u5f97\n\n-- \u5b9f\u969b\u306b\u3088\u304f\u4f7f\u3046\u30d1\u30bf\u30fc\u30f3\n-- \u300c\u524a\u9664\u6e08\u307f\u30fb\u30ad\u30e3\u30f3\u30bb\u30eb\u4ee5\u5916\u306e\u3059\u3079\u3066\u306e\u6ce8\u6587\u300d\nSELECT order_id, customer_name, total_amount\nFROM orders\nWHERE status_id NOT IN (8, 9)  -- 8=\u524a\u9664\u6e08\u307f, 9=\u30ad\u30e3\u30f3\u30bb\u30eb\nORDER BY created_at DESC;<\/pre>\n<\/div>\n\n\n\n<div style=\"background:#fef2f2;border:2px solid #dc2626;border-radius:8px;padding:20px 24px;margin:24px 0;\">\n  <div style=\"display:flex;align-items:center;gap:8px;margin-bottom:12px;\">\n    <span style=\"font-size:20px;\">&#9888;&#65039;<\/span>\n    <strong style=\"color:#dc2626;font-size:16px;\">NOT IN\u306bNULL\u304c\u542b\u307e\u308c\u308b\u3068\u5168\u4ef6\u30bc\u30ed\u306b\u306a\u308b\uff01<\/strong>\n  <\/div>\n  <p style=\"margin:0;font-size:15px;line-height:1.8;color:#333;\">\u3053\u308c\u306fSQL\u306e\u6700\u5927\u306e\u843d\u3068\u3057\u7a74\u306e\u4e00\u3064\u3067\u3059\u3002NOT IN (1, 2, NULL) \u306f\u5185\u90e8\u7684\u306bcol != 1 AND col != 2 AND col != NULL\u3068\u8a55\u4fa1\u3055\u308c\u307e\u3059\u3002NULL\u3068\u306e\u6bd4\u8f03\uff08col != NULL\uff09\u306f\u5e38\u306bNULL\uff08UNKNOWN\uff09\u3092\u8fd4\u3059\u305f\u3081\u3001AND\u6761\u4ef6\u5168\u4f53\u304cUNKNOWN\u306b\u306a\u308a\u3001\u3069\u306e\u884c\u3082WHERE\u6761\u4ef6\u3092\u30d1\u30b9\u3057\u307e\u305b\u3093\u3002\u7d50\u679c: 0\u4ef6\u304c\u8fd4\u308b\u3002\u30b5\u30d6\u30af\u30a8\u30ea\u3067NOT IN\u3092\u4f7f\u3046\u5834\u5408\u3001\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u7d50\u679c\u306bNULL\u304c\u542b\u307e\u308c\u308b\u3068\u540c\u69d8\u306b0\u4ef6\u306b\u306a\u308a\u307e\u3059\u3002\u5bfe\u7b56: NOT IN\u306e\u4ee3\u308f\u308a\u306bNOT EXISTS\u3092\u4f7f\u3046\u3001\u307e\u305f\u306fWHERE col IS NOT NULL\u3092\u30b5\u30d6\u30af\u30a8\u30ea\u306b\u8ffd\u52a0\u3059\u308b\u3002<\/p>\n<\/div>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;color:#d4d4d4;font-size:13px;line-height:1.8;font-family:'Consolas','Courier New',monospace;white-space:pre;\">-- NOT IN\u306eNULL\u554f\u984c\u306e\u5b9f\u4f8b\n-- \u4f8b: products\u30c6\u30fc\u30d6\u30eb\u306bcategory_id\u304cNULL\u306e\u884c\u304c\u3042\u308b\u5834\u5408\n\n-- NG: \u30b5\u30d6\u30af\u30a8\u30ea\u304cNULL\u3092\u8fd4\u3059\u3068products\u5168\u4ef6\u304c0\u4ef6\u306b\u306a\u308b\nSELECT *\nFROM orders\nWHERE product_id NOT IN (\n    SELECT product_id FROM discontinued_products\n    -- discontinued_products\u306bNULL\u306eproduct_id\u304c\u3042\u308b\u3068\u5168\u4ef6\u30bc\u30ed\uff01\n);\n\n-- \u5bfe\u7b561: \u30b5\u30d6\u30af\u30a8\u30ea\u306bIS NOT NULL\u3092\u8ffd\u52a0\nSELECT *\nFROM orders\nWHERE product_id NOT IN (\n    SELECT product_id FROM discontinued_products\n    WHERE product_id IS NOT NULL  -- NULL\u3092\u9664\u5916\n);\n\n-- \u5bfe\u7b562: NOT EXISTS\u3092\u4f7f\u3046\uff08NULL\u306b\u5b89\u5168\uff09\nSELECT *\nFROM orders o\nWHERE NOT EXISTS (\n    SELECT 1\n    FROM discontinued_products dp\n    WHERE dp.product_id = o.product_id\n);<\/pre>\n<\/div>\n\n\n\n<div style=\"background:#f8f9fa;border-left:4px solid #6b7280;border-radius:0 8px 8px 0;padding:16px 20px;margin:20px 0;\">\n  <p style=\"margin:0 0 4px;font-size:13px;font-weight:700;color:#6b7280;letter-spacing:1px;\">&#128218; \u7528\u8a9e\u89e3\u8aac<\/p>\n  <p style=\"margin:0;font-size:15px;line-height:1.7;\"><strong>SQL\u306b\u304a\u3051\u308b3\u5024\u8ad6\u7406\uff08TRUE\/FALSE\/UNKNOWN\uff09<\/strong>\uff1aSQL\u306fTRUE\/FALSE\u306e2\u5024\u8ad6\u7406\u3067\u306f\u306a\u304f\u3001NULL\u3092\u542b\u30803\u5024\u8ad6\u7406\uff08TRUE\/FALSE\/UNKNOWN\uff09\u3092\u4f7f\u3046\u3002NULL\u3068\u306e\u6bd4\u8f03\uff08col = NULL\u3001col != NULL\uff09\u306f\u3059\u3079\u3066UNKNOWN\u3092\u8fd4\u3059\uff08TRUE\u3067\u3082FALSE\u3067\u3082\u306a\u3044\uff09\u3002WHERE\u53e5\u306e\u6761\u4ef6\u304cUNKNOWN\u306e\u884c\u306f\u7d50\u679c\u306b\u542b\u307e\u308c\u306a\u3044\uff08FALSE\u3068\u540c\u69d8\u306b\u6271\u308f\u308c\u308b\uff09\u3002NULL\u5024\u306e\u5b58\u5728\u78ba\u8a8d\u306fcol IS NULL\u307e\u305f\u306fcol IS NOT NULL\u3067\u884c\u3046\uff08col = NULL\u306f\u4f7f\u3048\u306a\u3044\uff09\u3002<\/p>\n<\/div>\n\n\n\n<div id=\"sec-04\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">04<\/span>\n  <span class=\"section-label\" style=\"display:block;\">SUBQUERY<\/span>\n  <span class=\"section-title\" style=\"display:block;\">IN\u53e5\u3068\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u7d44\u307f\u5408\u308f\u305b<\/span>\n  <span class=\"section-desc\">\u52d5\u7684\u306a\u30ea\u30b9\u30c8\u3092SELECT\u3067\u751f\u6210\u3057\u3066IN\u306b\u6e21\u3059\u5f37\u529b\u306a\u30d1\u30bf\u30fc\u30f3<\/span>\n<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">IN\u53e5\u306e\u5024\u30ea\u30b9\u30c8\u3092\u56fa\u5b9a\u5024\u3067\u306a\u304f<strong>\u30b5\u30d6\u30af\u30a8\u30ea\uff08SELECT\u6587\uff09<\/strong>\u3067\u751f\u6210\u3059\u308b\u3053\u3068\u3067\u3001\u52d5\u7684\u306a\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u308c\u306fSQL\u306e\u4e2d\u3067\u3082\u6700\u3082\u983b\u7e41\u306b\u4f7f\u308f\u308c\u308b\u5f37\u529b\u306a\u30d1\u30bf\u30fc\u30f3\u306e\u4e00\u3064\u3067\u3059\u3002<\/p>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;color:#d4d4d4;font-size:13px;line-height:1.8;font-family:'Consolas','Courier New',monospace;white-space:pre;\">-- IN\u53e5 + \u30b5\u30d6\u30af\u30a8\u30ea\u306e\u57fa\u672c\u5f62\nSELECT \u30ab\u30e9\u30e0\nFROM \u30c6\u30fc\u30d6\u30ebA\nWHERE \u30ab\u30e9\u30e0 IN (\n    SELECT \u30ab\u30e9\u30e0 FROM \u30c6\u30fc\u30d6\u30ebB\n    WHERE \u6761\u4ef6\n);\n\n-- \u5b9f\u4f8b1: \u6ce8\u6587\u306e\u3042\u308b\u9867\u5ba2\u3060\u3051\u3092\u53d6\u5f97\nSELECT customer_id, name, email\nFROM customers\nWHERE customer_id IN (\n    SELECT DISTINCT customer_id\n    FROM orders\n    WHERE created_at >= '2026-01-01'  -- \u4eca\u5e74\u6ce8\u6587\u3057\u305f\u9867\u5ba2\u306eID\n);\n\n-- \u5b9f\u4f8b2: \u7279\u5b9a\u30ab\u30c6\u30b4\u30ea\u306e\u5546\u54c1\u3092\u8cfc\u5165\u3057\u305f\u6ce8\u6587\u3092\u53d6\u5f97\nSELECT *\nFROM orders\nWHERE product_id IN (\n    SELECT product_id\n    FROM products\n    WHERE category_id = 5  -- \u30ab\u30c6\u30b4\u30eaID=5\u306e\u5546\u54c1\n);\n\n-- \u5b9f\u4f8b3: \u96c6\u8a08\u3092\u4f7f\u3063\u305f\u30b5\u30d6\u30af\u30a8\u30ea\n-- \u300c\u58f2\u4e0a\u7dcf\u984d\u304c10\u4e07\u5186\u4ee5\u4e0a\u306e\u9867\u5ba2\u306e\u8a73\u7d30\u3092\u53d6\u5f97\u300d\nSELECT *\nFROM customers\nWHERE customer_id IN (\n    SELECT customer_id\n    FROM orders\n    GROUP BY customer_id\n    HAVING SUM(total_amount) >= 100000\n);<\/pre>\n<\/div>\n\n\n\n<div class=\"g-flow-row\" style=\"margin:24px 0;\">\n  <div class=\"g-flow-item\"><strong>\u5916\u5074\u306e\u30af\u30a8\u30ea<\/strong><br><span style=\"font-size:12px;\">customers\u304b\u3089<br>\u53d6\u5f97<\/span><\/div>\n  <div class=\"g-flow-arrow\">&#8594;<\/div>\n  <div class=\"g-flow-item\"><strong>IN\u53e5\u306e\u30b5\u30d6\u30af\u30a8\u30ea\u3092\u5b9f\u884c<\/strong><br><span style=\"font-size:12px;\">orders\u304b\u3089<br>customer_id\u30ea\u30b9\u30c8\u751f\u6210<\/span><\/div>\n  <div class=\"g-flow-arrow\">&#8594;<\/div>\n  <div class=\"g-flow-item\"><strong>\u4e00\u81f4\u3059\u308b\u884c\u3092\u30d5\u30a3\u30eb\u30bf<\/strong><br><span style=\"font-size:12px;\">customers\u306ecustomer_id<br>\u304c\u30ea\u30b9\u30c8\u306b\u3042\u308b\u304b<\/span><\/div>\n  <div class=\"g-flow-arrow\">&#8594;<\/div>\n  <div class=\"g-flow-item\"><strong>\u7d50\u679c\u3092\u8fd4\u3059<\/strong><br><span style=\"font-size:12px;\">\u6761\u4ef6\u306b\u5408\u3046\u9867\u5ba2\u884c<\/span><\/div>\n<\/div>\n\n\n\n<div id=\"sec-05\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">05<\/span>\n  <span class=\"section-label\" style=\"display:block;\">EXISTS<\/span>\n  <span class=\"section-title\" style=\"display:block;\">IN vs EXISTS\uff1a\u3069\u3061\u3089\u3092\u9078\u3076\u3079\u304d\u304b<\/span>\n  <span class=\"section-desc\">\u5b9f\u884c\u8a08\u753b\u30fbNULL\u5b89\u5168\u6027\u30fb\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u89b3\u70b9\u3067\u306e\u4f7f\u3044\u5206\u3051<\/span>\n<\/h2>\n\n\n\n<div style=\"background:#f8f9fa;border-left:4px solid #6b7280;border-radius:0 8px 8px 0;padding:16px 20px;margin:20px 0;\">\n  <p style=\"margin:0 0 4px;font-size:13px;font-weight:700;color:#6b7280;letter-spacing:1px;\">&#128218; \u7528\u8a9e\u89e3\u8aac<\/p>\n  <p style=\"margin:0;font-size:15px;line-height:1.7;\"><strong>EXISTS\u53e5<\/strong>\uff1aWHERE EXISTS (\u30b5\u30d6\u30af\u30a8\u30ea) \u306f\u300c\u30b5\u30d6\u30af\u30a8\u30ea\u304c1\u884c\u4ee5\u4e0a\u7d50\u679c\u3092\u8fd4\u3059\u306a\u3089TRUE\u300d\u3092\u610f\u5473\u3059\u308b\u3002IN\u3068\u7570\u306a\u308a\u3001EXISTS\u306f\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea\uff08\u5916\u5074\u306e\u884c\u3092\u53c2\u7167\u3059\u308b\u30b5\u30d6\u30af\u30a8\u30ea\uff09\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u4f7f\u3046\u3053\u3068\u304c\u591a\u3044\u3002SELECT 1\uff08\u5b9a\u6570\uff09\u3092\u30b5\u30d6\u30af\u30a8\u30ea\u306eSELECT\u53e5\u306b\u4f7f\u3046\u306e\u306f\u3001EXISTS\u306f\u5b58\u5728\u78ba\u8a8d\u3057\u304b\u3057\u306a\u3044\u305f\u3081\u3069\u306e\u5024\u3092\u8fd4\u3057\u3066\u3082\u826f\u3044\u304b\u3089\u3002NULL\u304c\u542b\u307e\u308c\u3066\u3082\u6b63\u3057\u304f\u52d5\u4f5c\u3059\u308b\u305f\u3081NOT IN\u306e\u4ee3\u308f\u308a\u306bNOT EXISTS\u3092\u4f7f\u3046\u3053\u3068\u304c\u63a8\u5968\u3055\u308c\u308b\u3002<\/p>\n<\/div>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;color:#d4d4d4;font-size:13px;line-height:1.8;font-family:'Consolas','Courier New',monospace;white-space:pre;\">-- IN\u53e5\u3067\u66f8\u304f\u5834\u5408\nSELECT *\nFROM customers c\nWHERE c.customer_id IN (\n    SELECT o.customer_id\n    FROM orders o\n    WHERE o.status_id = 1\n);\n\n-- EXISTS\u53e5\u3067\u66f8\u304f\u5834\u5408\uff08\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea\uff09\nSELECT *\nFROM customers c\nWHERE EXISTS (\n    SELECT 1\n    FROM orders o\n    WHERE o.customer_id = c.customer_id  -- \u5916\u5074\u306e\u884c\u3092\u53c2\u7167\uff08\u76f8\u95a2\uff09\n      AND o.status_id = 1\n);\n\n-- \u3069\u3061\u3089\u3082\u540c\u3058\u7d50\u679c\u3060\u304c\u5b9f\u884c\u8a08\u753b\u304c\u7570\u306a\u308b\u5834\u5408\u304c\u3042\u308b\n-- \u6700\u65b0DB\u306e\u30aa\u30d7\u30c6\u30a3\u30de\u30a4\u30b6\u306f\u3069\u3061\u3089\u3082\u6700\u9069\u5316\u3059\u308b\u304c\u3001\n-- NULL\u304c\u542b\u307e\u308c\u308b\u5834\u5408\u306e\u6319\u52d5\u304c\u6c7a\u5b9a\u7684\u306b\u9055\u3046<\/pre>\n<\/div>\n\n\n\n<table>\n<thead><tr><th>\u6bd4\u8f03\u8ef8<\/th><th>IN (\u30b5\u30d6\u30af\u30a8\u30ea)<\/th><th>EXISTS<\/th><\/tr><\/thead>\n<tbody>\n<tr><td>NULL\u3078\u306e\u5b89\u5168\u6027<\/td><td>NOT IN\u3067NULL\u554f\u984c\u3042\u308a<\/td><td>NOT EXISTS\u306fNULL\u5b89\u5168<\/td><\/tr>\n<tr><td>\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u5b9f\u884c<\/td><td>\u5148\u306b\u30b5\u30d6\u30af\u30a8\u30ea\u3092\u5b9f\u884c\uff08\u975e\u76f8\u95a2\uff09<\/td><td>\u5916\u5074\u306e\u884c\u3054\u3068\u306b\u30b5\u30d6\u30af\u30a8\u30ea\u5b9f\u884c\uff08\u76f8\u95a2\uff09<\/td><\/tr>\n<tr><td>\u7d50\u679c\u304c\u5927\u304d\u3044\u5834\u5408<\/td><td>IN\u53e5\u306e\u30ea\u30b9\u30c8\u304c\u5927\u304d\u304f\u306a\u308b<\/td><td>\u65e9\u671f\u6253\u3061\u5207\u308a\u304c\u52b9\u304f\u5834\u5408\u3042\u308a<\/td><\/tr>\n<tr><td>\u7d50\u679c\u304c\u5c0f\u3055\u3044\u5834\u5408<\/td><td>\u52b9\u7387\u7684\u306a\u3053\u3068\u304c\u591a\u3044<\/td><td>\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea\u306f\u884c\u3054\u3068\u306b\u5b9f\u884c<\/td><\/tr>\n<tr><td>\u53ef\u8aad\u6027<\/td><td>\u76f4\u611f\u7684\u3067\u5206\u304b\u308a\u3084\u3059\u3044<\/td><td>\u6163\u308c\u304c\u5fc5\u8981\u3060\u304c\u6b63\u78ba\u306a\u610f\u56f3\u3092\u8868\u73fe<\/td><\/tr>\n<tr><td>\u63a8\u5968\u30b1\u30fc\u30b9<\/td><td>\u5c0f\u301c\u4e2d\u898f\u6a21\u306e\u30ea\u30b9\u30c8<\/td><td>NOT EXISTS\uff08NULL\u306b\u5b89\u5168\uff09\u3001\u76f8\u95a2\u6761\u4ef6\u304c\u8907\u96d1\u306a\u5834\u5408<\/td><\/tr>\n<\/tbody>\n<\/table>\n\n\n\n<div style=\"background:#f0fdf4;border:1px solid #22c55e;border-radius:8px;padding:20px 24px;margin:24px 0;\">\n  <div style=\"display:flex;align-items:center;gap:8px;margin-bottom:12px;\">\n    <span style=\"font-size:18px;\">&#128161;<\/span>\n    <strong style=\"color:#16a34a;font-size:15px;\">\u73fe\u4ee3\u306eDB\u3067IN vs EXISTS\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5dee<\/strong>\n  <\/div>\n  <p style=\"margin:0;font-size:15px;line-height:1.8;color:#333;\">MySQL 5.6+\u3001PostgreSQL\u3001SQL Server\u306a\u3069\u306e\u6700\u65b0DB\u3067\u306f\u3001\u30af\u30a8\u30ea\u30aa\u30d7\u30c6\u30a3\u30de\u30a4\u30b6\u304cIN\u53e5\u3092EXISTS\u306b\u5909\u63db\u3057\u305f\u308a\u3001\u30cf\u30c3\u30b7\u30e5\u7d50\u5408\u30fb\u30cd\u30b9\u30c6\u30c3\u30c9\u30eb\u30fc\u30d7\u7d50\u5408\u306a\u3069\u3092\u81ea\u52d5\u9078\u629e\u3057\u307e\u3059\u3002\u300cIN\u306fEXISTS\u3088\u308a\u9045\u3044\u300d\u306f\u53e4\u3044\u8a71\u3067\u3001\u73fe\u5728\u306f\u307b\u307c\u540c\u7b49\u306e\u30b1\u30fc\u30b9\u304c\u591a\u3044\u3067\u3059\u3002EXPLAIN\uff08\u5b9f\u884c\u8a08\u753b\uff09\u3067\u78ba\u8a8d\u3059\u308b\u306e\u304c\u78ba\u5b9f\u3067\u3059\u3002\u305f\u3060\u3057NOT IN\u306eNULL\u554f\u984c\u306f\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3067\u306f\u306a\u304f\u6b63\u78ba\u6027\u306e\u554f\u984c\u306e\u305f\u3081NOT EXISTS\u3092\u512a\u5148\u3059\u3079\u304d\u3067\u3059\u3002<\/p>\n<\/div>\n\n\n\n<div id=\"sec-06\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">06<\/span>\n  <span class=\"section-label\" style=\"display:block;\">NULL_TRAP<\/span>\n  <span class=\"section-title\" style=\"display:block;\">IN\u53e5\u306bNULL\u304c\u542b\u307e\u308c\u308b\u5834\u5408\u306e\u843d\u3068\u3057\u7a74<\/span>\n  <span class=\"section-desc\">NULL\u306fIN\u3067\u4e00\u81f4\u3057\u306a\u3044\u30fbNOT IN\u3067\u5168\u4ef6\u30bc\u30ed\u306b\u306a\u308b\u52d5\u4f5c\u306e\u7406\u89e3<\/span>\n<\/h2>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;color:#d4d4d4;font-size:13px;line-height:1.8;font-family:'Consolas','Courier New',monospace;white-space:pre;\">-- IN\u53e5\u3067\u306eNULL\u306e\u52d5\u4f5c\n\n-- \u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\nCREATE TABLE test_items (id INT, name VARCHAR(50));\nINSERT INTO test_items VALUES (1, '\u308a\u3093\u3054'), (2, NULL), (3, '\u307f\u304b\u3093');\n\n-- NULL\u306fIN\u3067\u300c\u4e00\u81f4\u300d\u306b\u306a\u3089\u306a\u3044\n-- name IN ('\u308a\u3093\u3054', NULL, '\u307f\u304b\u3093') \u306f\n-- name = '\u308a\u3093\u3054' OR name = NULL OR name = '\u307f\u304b\u3093'\n-- name = NULL \u306fUNKNOWN\uff08TRUE\u306b\u306a\u3089\u306a\u3044\uff09\n\nSELECT * FROM test_items WHERE name IN ('\u308a\u3093\u3054', NULL);\n-- \u7d50\u679c: id=1(\u308a\u3093\u3054)\u306e\u307f\n-- id=2(NULL)\u306f\u300cNULL\u306fNULL\u3068\u7b49\u3057\u304f\u306a\u3044\u300d\u305f\u3081\u542b\u307e\u308c\u306a\u3044\n\n-- NULL\u306e\u884c\u3092\u53d6\u5f97\u3059\u308b\u306b\u306fIS NULL\u3092\u4f7f\u3046\nSELECT * FROM test_items WHERE name IS NULL;\n-- \u7d50\u679c: id=2\n\n-- NULL\u3092\u542b\u3080\u884c\u3082\u4e00\u7dd2\u306b\u53d6\u5f97\u3057\u305f\u3044\u5834\u5408\nSELECT * FROM test_items\nWHERE name IN ('\u308a\u3093\u3054', '\u307f\u304b\u3093') OR name IS NULL;\n-- \u7d50\u679c: id=1, id=2, id=3<\/pre>\n<\/div>\n\n\n\n<div style=\"background:#fef2f2;border:2px solid #dc2626;border-radius:8px;padding:20px 24px;margin:24px 0;\">\n  <div style=\"display:flex;align-items:center;gap:8px;margin-bottom:12px;\">\n    <span style=\"font-size:20px;\">&#9888;&#65039;<\/span>\n    <strong style=\"color:#dc2626;font-size:16px;\">NOT IN\u3068NULL\u306e\u7d44\u307f\u5408\u308f\u305b\u306f\u5fc5\u305a\u628a\u63e1\u3059\u308b<\/strong>\n  <\/div>\n  <p style=\"margin:0;font-size:15px;line-height:1.8;color:#333;\">NOT IN\u53e5\u306e\u30ea\u30b9\u30c8\uff08\u307e\u305f\u306f\u53c2\u7167\u3059\u308b\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u7d50\u679c\uff09\u306bNULL\u304c1\u3064\u3067\u3082\u542b\u307e\u308c\u308b\u3068\u3001WHERE\u6761\u4ef6\u304c\u5168\u884c\u3067UNKNOWN\u3068\u306a\u308a\u3001\u7d50\u679c\u304c\u5e38\u306b0\u4ef6\u306b\u306a\u308a\u307e\u3059\u3002\u300c\u3055\u3063\u304d\u307e\u3067\u52d5\u3044\u3066\u3044\u305fNOT IN\u30af\u30a8\u30ea\u304c\u7a81\u71360\u4ef6\u306b\u306a\u3063\u305f\u300d\u3068\u3044\u3046\u5834\u5408\u3001\u53c2\u7167\u5148\u30c6\u30fc\u30d6\u30eb\u306bNULL\u304c\u8ffd\u52a0\u3055\u308c\u305f\u3053\u3068\u304c\u539f\u56e0\u3067\u3042\u308b\u3053\u3068\u304c\u591a\u3044\u3067\u3059\u3002\u672c\u756a\u74b0\u5883\u3067\u306eNOT IN\u306f\u7279\u306b\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<\/div>\n\n\n\n<div id=\"sec-07\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">07<\/span>\n  <span class=\"section-label\" style=\"display:block;\">PERFORMANCE<\/span>\n  <span class=\"section-title\" style=\"display:block;\">IN\u53e5\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u6700\u9069\u5316<\/span>\n  <span class=\"section-desc\">\u5927\u91cf\u30ea\u30b9\u30c8\u30fb\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u30fb\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u5b9f\u884c\u8a08\u753b\u3092\u8003\u616e\u3059\u308b<\/span>\n<\/h2>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;color:#d4d4d4;font-size:13px;line-height:1.8;font-family:'Consolas','Courier New',monospace;white-space:pre;\">-- 1. \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u6d3b\u7528\u3059\u308bIN\u53e5\n-- IN\u53e5\u306e\u5bfe\u8c61\u30ab\u30e9\u30e0\u306b\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u304c\u3042\u308c\u3070\u52b9\u7387\u7684\u306b\u691c\u7d22\u3067\u304d\u308b\n-- CREATE INDEX idx_status ON orders(status_id);\n\nEXPLAIN SELECT *\nFROM orders\nWHERE status_id IN (1, 2, 3);\n-- type=range \u3067\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f7f\u3063\u305f\u7bc4\u56f2\u30b9\u30ad\u30e3\u30f3\n\n-- 2. IN\u53e5\u306e\u30ea\u30b9\u30c8\u304c\u5927\u91cf\u306e\u5834\u5408\u306fJOIN\u3092\u691c\u8a0e\n-- NG\uff08\u30ea\u30b9\u30c8\u304c1000\u4ef6\u4ee5\u4e0a\u306b\u306a\u308b\u5834\u5408\uff09\nSELECT * FROM orders\nWHERE product_id IN (1, 2, 3, 4, ... 1000\u4ef6 ...);\n\n-- OK: \u4e00\u6642\u30c6\u30fc\u30d6\u30eb\u3084JOIN\u3092\u4f7f\u3046\n-- \uff08\u5bfe\u8c61ID\u3092\u30c6\u30fc\u30d6\u30eb\u306b\u5165\u308c\u3066\u304a\u304f\uff09\nSELECT o.*\nFROM orders o\nINNER JOIN target_products tp ON o.product_id = tp.product_id;\n\n-- 3. \u30b5\u30d6\u30af\u30a8\u30ea\u306eIN\u53e5\u306f\u76f8\u95a2\u3055\u305b\u306a\u3044\uff08\u975e\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea\u306b\u3059\u308b\uff09\n-- NG: \u5916\u5074\u306e\u30af\u30a8\u30ea\u306e\u884c\u3054\u3068\u306b\u30b5\u30d6\u30af\u30a8\u30ea\u304c\u5b9f\u884c\u3055\u308c\u308b\n-- \uff08\u5b9f\u969b\u306b\u306f\u30aa\u30d7\u30c6\u30a3\u30de\u30a4\u30b6\u304c\u6700\u9069\u5316\u3059\u308b\u304c\u3001\u610f\u56f3\u7684\u306b\u76f8\u95a2\u3055\u305b\u306a\u3044\uff09\nSELECT *\nFROM customers c\nWHERE c.customer_id IN (\n    SELECT customer_id FROM orders\n    WHERE orders.customer_id = c.customer_id  -- \u76f8\u95a2\uff08\u907f\u3051\u3089\u308c\u308b\u306a\u3089\uff09\n);\n\n-- OK: \u975e\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea\uff08\u5148\u306b\u30ea\u30b9\u30c8\u3092\u4f5c\u3063\u3066\u30d5\u30a3\u30eb\u30bf\uff09\nSELECT *\nFROM customers c\nWHERE c.customer_id IN (\n    SELECT DISTINCT customer_id FROM orders  -- \u76f8\u95a2\u306a\u3057\n);<\/pre>\n<\/div>\n\n\n\n<div style=\"background:#f8f9fa;border-left:4px solid #6b7280;border-radius:0 8px 8px 0;padding:16px 20px;margin:20px 0;\">\n  <p style=\"margin:0 0 4px;font-size:13px;font-weight:700;color:#6b7280;letter-spacing:1px;\">&#128218; \u7528\u8a9e\u89e3\u8aac<\/p>\n  <p style=\"margin:0;font-size:15px;line-height:1.7;\"><strong>\u5b9f\u884c\u8a08\u753b\uff08EXPLAIN\uff09<\/strong>\uff1aSQL\u30af\u30a8\u30ea\u304c\u3069\u306e\u3088\u3046\u306b\u5b9f\u884c\u3055\u308c\u308b\u304b\u306e\u8a08\u753b\u3092\u8868\u793a\u3059\u308b\u30b3\u30de\u30f3\u30c9\u3002MySQL\/PostgreSQL\/SQL Server\u3067\u4f7f\u7528\u53ef\u80fd\u3002EXPLAIN\u306e\u51fa\u529b\u3067type\u304cALL\u306f\u30c6\u30fc\u30d6\u30eb\u30d5\u30eb\u30b9\u30ad\u30e3\u30f3\uff08\u9045\u3044\uff09\u3001ref\u3084range\u306f\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f7f\u7528\uff08\u901f\u3044\uff09\u3092\u610f\u5473\u3059\u308b\u3002IN\u53e5\u3084WHERE\u53e5\u306e\u52b9\u7387\u5316\u306e\u305f\u3081EXPLAIN\u3067\u5b9f\u884c\u8a08\u753b\u3092\u78ba\u8a8d\u3057\u3001\u9045\u3044\u5834\u5408\u306f\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u8ffd\u52a0\u3059\u308b\u306e\u304c\u57fa\u672c\u7684\u306a\u30a2\u30d7\u30ed\u30fc\u30c1\u3002<\/p>\n<\/div>\n\n\n\n<div class=\"g-flow-row\" style=\"margin:24px 0;\">\n  <div class=\"g-flow-item\"><strong>\u30af\u30a8\u30ea\u3092\u66f8\u304f<\/strong><br><span style=\"font-size:12px;\">IN\u53e5\u3067\u30d5\u30a3\u30eb\u30bf\u6761\u4ef6<\/span><\/div>\n  <div class=\"g-flow-arrow\">&#8594;<\/div>\n  <div class=\"g-flow-item\"><strong>EXPLAIN\u3067\u5b9f\u884c\u8a08\u753b\u78ba\u8a8d<\/strong><br><span style=\"font-size:12px;\">type\u304cALL\u306a\u3089\u8981\u6539\u5584<br>range\u306a\u3089OK<\/span><\/div>\n  <div class=\"g-flow-arrow\">&#8594;<\/div>\n  <div class=\"g-flow-item\"><strong>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u8ffd\u52a0<\/strong><br><span style=\"font-size:12px;\">IN\u53e5\u306e\u5bfe\u8c61\u30ab\u30e9\u30e0\u306b<br>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u4f5c\u6210<\/span><\/div>\n  <div class=\"g-flow-arrow\">&#8594;<\/div>\n  <div class=\"g-flow-item\"><strong>\u5927\u91cf\u30ea\u30b9\u30c8\u306fJOIN\u306b\u5909\u66f4<\/strong><br><span style=\"font-size:12px;\">1000\u4ef6\u8d85\u306f\u30c6\u30fc\u30d6\u30ebJOIN\u304c<br>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u826f\u3044\u3053\u3068\u3082<\/span><\/div>\n<\/div>\n\n\n\n<div id=\"sec-08\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">08<\/span>\n  <span class=\"section-label\" style=\"display:block;\">AI_ASSIST<\/span>\n  <span class=\"section-title\" style=\"display:block;\">Claude Code\u3067SQL IN\u53e5\u30af\u30a8\u30ea\u3092\u81ea\u52d5\u751f\u6210\u3059\u308b<\/span>\n  <span class=\"section-desc\">\u30c6\u30fc\u30d6\u30eb\u69cb\u9020\u3068\u53d6\u5f97\u6761\u4ef6\u3092\u4f1d\u3048\u308b\u3060\u3051\u3067\u6b63\u78ba\u306aSQL\u304c\u5373\u751f\u6210<\/span>\n<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Claude Code<\/strong>\u3092\u4f7f\u3048\u3070\u3001\u30c6\u30fc\u30d6\u30eb\u306e\u69cb\u9020\u3068\u300c\u4f55\u3092\u53d6\u5f97\u3057\u305f\u3044\u304b\u300d\u3092\u65e5\u672c\u8a9e\u3067\u8aac\u660e\u3059\u308b\u3060\u3051\u3067\u3001\u9069\u5207\u306aIN\u53e5\u3084NOT EXISTS\u30fbJOIN\u3092\u4f7f\u3063\u305fSQL\u30af\u30a8\u30ea\u304c\u5373\u5ea7\u306b\u751f\u6210\u3055\u308c\u307e\u3059\u3002EXPLAIN\u306e\u7d50\u679c\u3092\u8cbc\u3063\u3066\u300c\u3053\u306e\u30af\u30a8\u30ea\u3092\u6700\u9069\u5316\u3057\u3066\u300d\u3068\u3044\u3046\u4f9d\u983c\u306b\u3082\u5bfe\u5fdc\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<table>\n<thead><tr><th>\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9<\/th><th>Claude Code\u3078\u306e\u6307\u793a\u4f8b<\/th><\/tr><\/thead>\n<tbody>\n<tr><td>\u57fa\u672c\u7684\u306aIN\u53e5<\/td><td>\u300corders\u30c6\u30fc\u30d6\u30eb\u306estatus_id\u304c1,2,5\u306e\u6ce8\u6587\u3092\u53d6\u5f97\u3059\u308bSQL\u3092\u66f8\u3044\u3066\u3002status_id, customer_name, total_amount\u3092\u53d6\u5f97\u3002\u300d<\/td><\/tr>\n<tr><td>\u30b5\u30d6\u30af\u30a8\u30eaIN<\/td><td>\u300ccustomers\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u3001orders\u30c6\u30fc\u30d6\u30eb\u306b1\u4ef6\u4ee5\u4e0a\u6ce8\u6587\u304c\u3042\u308b\u9867\u5ba2\u306e\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308bSQL\u3002IN\u53e5\u3068\u30b5\u30d6\u30af\u30a8\u30ea\u3092\u4f7f\u3063\u3066\u3002\u300d<\/td><\/tr>\n<tr><td>NOT IN\u306eNULL\u5bfe\u7b56<\/td><td>\u300cdiscontinued_products\u306b\u306a\u3044product_id\u306e\u6ce8\u6587\u3092\u53d6\u5f97\u3057\u305f\u3044\u3002NULL\u304c\u542b\u307e\u308c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u305f\u3081NOT EXISTS\u3067\u66f8\u3044\u3066\u3002\u300d<\/td><\/tr>\n<tr><td>EXPLAIN\u6700\u9069\u5316<\/td><td>\u300c\u4ee5\u4e0b\u306eSQL\u306eEXPLAIN\u306e\u51fa\u529b\u304ctype=ALL\u3067\u3059\u3002IN\u53e5\u306e\u5bfe\u8c61\u30ab\u30e9\u30e0\u306b\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u8ffd\u52a0\u3059\u308b\u65b9\u6cd5\u3068\u3001JOIN\u3067\u66f8\u304d\u76f4\u3059\u30d0\u30ea\u30a8\u30fc\u30b7\u30e7\u30f3\u3092\u6559\u3048\u3066\u3002[SQL\u3068EXPLAIN\u3092\u8cbc\u308a\u4ed8\u3051]\u300d<\/td><\/tr>\n<\/tbody>\n<\/table>\n\n\n\n<div class=\"balloon-wrap is-right\">\n  <div class=\"balloon-icon\">\n    <img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/04\/yamazaki-avatar.png\" alt=\"AI\u9b3c\u7ba1\u7406\u5c71\u5d0e\">\n    <span class=\"balloon-name\">AI\u9b3c\u7ba1\u7406\u5c71\u5d0e<\/span>\n  <\/div>\n  <div class=\"balloon-body\">SQL\u306eIN\u53e5\u3067\u7279\u306b\u5f79\u7acb\u3064\u306e\u306f\u300cNOT IN\u306eNULL\u554f\u984c\u3092\u81ea\u52d5\u7684\u306b\u56de\u907f\u3057\u305fNOT EXISTS\u3067\u66f8\u3044\u3066\u300d\u3068\u3044\u3046\u6307\u793a\u3067\u3059\u3002\u300cNOT IN\u3092\u4f7f\u3046\u306a\u3001NOT EXISTS\u3067\u66f8\u3044\u3066\u300d\u3068\u4f1d\u3048\u308b\u3060\u3051\u3067NULL\u5b89\u5168\u306aSQL\u304c\u8fd4\u3063\u3066\u304f\u308b\u305f\u3081\u3001NULL\u304c\u6df7\u5728\u3059\u308bDB\u3067\u306e\u8aa4\u30af\u30a8\u30ea\u9632\u6b62\u306b\u52b9\u679c\u7684\u3067\u3059\u3002<\/div>\n<\/div>\n\n\n\n<div style=\"background:#f8f9fa;border-left:4px solid #6b7280;border-radius:0 8px 8px 0;padding:16px 20px;margin:20px 0;\">\n  <p style=\"margin:0 0 4px;font-size:13px;font-weight:700;color:#6b7280;letter-spacing:1px;\">&#128218; \u7528\u8a9e\u89e3\u8aac<\/p>\n  <p style=\"margin:0;font-size:15px;line-height:1.7;\"><strong>\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea<\/strong>\uff1a\u5916\u5074\u306eSELECT\u6587\uff08\u4e3b\u30af\u30a8\u30ea\uff09\u306e\u884c\u3092\u53c2\u7167\u3059\u308b\u30b5\u30d6\u30af\u30a8\u30ea\u3002\u5916\u5074\u306e\u884c\u304c\u5909\u308f\u308b\u305f\u3073\u306b\u30b5\u30d6\u30af\u30a8\u30ea\u304c\u518d\u5b9f\u884c\u3055\u308c\u308b\u3002EXISTS\u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u5834\u5408\u306b\u591a\u3044\u3002\u4f8b: WHERE EXISTS (SELECT 1 FROM orders o WHERE o.customer_id = c.customer_id) \u306e\u3088\u3046\u306bc.customer_id\u3067\u5916\u5074\u306e\u884c\u3092\u53c2\u7167\u3059\u308b\u306e\u304c\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea\u3002\u975e\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea\u306f\u5916\u5074\u306e\u884c\u3092\u53c2\u7167\u305b\u305a\u5148\u306b1\u56de\u3060\u3051\u5b9f\u884c\u3055\u308c\u3066\u30ea\u30b9\u30c8\u3092\u751f\u6210\u3059\u308b\u3002IN (SELECT ...)\u306f\u901a\u5e38\u975e\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea\u3068\u3057\u3066\u6271\u308f\u308c\u308b\u3002<\/p>\n<\/div>\n\n\n\n<div id=\"sec-09\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">09<\/span>\n  <span class=\"section-label\" style=\"display:block;\">CONCLUSION<\/span>\n  <span class=\"section-title\" style=\"display:block;\">\u307e\u3068\u3081\uff1aSQL IN\u53e5\u306e\u91cd\u8981\u30dd\u30a4\u30f3\u30c8<\/span>\n  <span class=\"section-desc\">\u57fa\u672c\u304b\u3089\u843d\u3068\u3057\u7a74\u30fb\u6700\u9069\u5316\u307e\u3067<\/span>\n<\/h2>\n\n\n\n<div style=\"background:#fafafa;border-radius:8px;padding:16px 20px;margin:16px 0;border-left:4px solid #dc2626;\">\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span>IN\u53e5\u306f<strong>WHERE col IN (v1, v2, v3)<\/strong>\u3067\u8907\u6570\u5024\u306eOR\u6761\u4ef6\u3092\u7c21\u6f54\u306b\u66f8\u304f<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span>OR\u6f14\u7b97\u5b50\u3088\u308a<strong>IN\u53e5\u306e\u307b\u3046\u304c\u53ef\u8aad\u6027\u304c\u9ad8\u304f<\/strong>\u4fdd\u5b88\u3057\u3084\u3059\u3044<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>NOT IN\u306e\u30ea\u30b9\u30c8\u306bNULL\u304c\u542b\u307e\u308c\u308b\u3068\u5168\u4ef6\u30bc\u30ed<\/strong>\u2014\u2014NOT EXISTS\u3067\u4ee3\u66ff\u3059\u308b<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span>IN\u53e5\u306b<strong>\u30b5\u30d6\u30af\u30a8\u30ea<\/strong>\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3068\u52d5\u7684\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u304c\u53ef\u80fd<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>NOT IN\u306eNULL\u554f\u984c<\/strong>\u306b\u5bfe\u3057\u3066NOT EXISTS\u306f\u5b89\u5168<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span>IN\u53e5\u306e\u5bfe\u8c61\u30ab\u30e9\u30e0\u306b<strong>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9<\/strong>\u304c\u3042\u308c\u3070\u9ad8\u901f\u3002EXPLAIN\u3067\u78ba\u8a8d\u3059\u308b<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span>\u5927\u91cf\u30ea\u30b9\u30c8\uff081000\u4ef6\u8d85\uff09\u306fIN\u53e5\u3088\u308a<strong>JOIN\u3092\u691c\u8a0e<\/strong><\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>Claude Code<\/strong>\u306b\u30c6\u30fc\u30d6\u30eb\u69cb\u9020\u3068\u53d6\u5f97\u6761\u4ef6\u3092\u4f1d\u3048\u308c\u3070\u6b63\u78ba\u306aSQL\u304c\u5373\u751f\u6210<\/span><\/div>\n\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">SQL\u3092AI\u3067\u52b9\u7387\u5316\u30fb\u5b66\u7fd2\u3057\u305f\u3044\u65b9\u3078<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">IN\u53e5\u306b\u9650\u3089\u305a\u3001JOIN\u306e\u6700\u9069\u5316\u30fb\u30a6\u30a3\u30f3\u30c9\u30a6\u95a2\u6570\u30fb\u8907\u96d1\u306a\u30b5\u30d6\u30af\u30a8\u30ea\u306fClaude Code\u3068\u306e\u7d44\u307f\u5408\u308f\u305b\u3067\u5927\u5e45\u306b\u52b9\u7387\u5316\u3067\u304d\u307e\u3059\u3002<br>AI\u9b3c\u7ba1\u7406\u3067\u306f\u3001\u30c7\u30fc\u30bf\u6d3b\u7528\u30fbSQL\u696d\u52d9\u306eAI\u6d3b\u7528\u8a2d\u8a08\u30fb\u5b9f\u88c5\u652f\u63f4\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"balloon-wrap\">\n  <div class=\"balloon-icon\">\n    <img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/04\/ceo-sugasawa.jpg\" alt=\"\u4ee3\u8868\u83c5\u6fa4\">\n    <span class=\"balloon-name\">\u4ee3\u8868\u83c5\u6fa4<\/span>\n  <\/div>\n  <div class=\"balloon-body\">\u300c\u3053\u306eSQL\u304c\u9045\u3044\u539f\u56e0\u3092\u8abf\u3079\u305f\u3044\u300d\u300cJOIN\u30fbIN\u30fbEXISTS\u306e\u3069\u308c\u3092\u4f7f\u3046\u3079\u304d\u304b\u308f\u304b\u3089\u306a\u3044\u300d\u3068\u3044\u3046\u76f8\u8ac7\u306f\u591a\u304f\u3042\u308a\u307e\u3059\u3002EXPLAIN\u306e\u51fa\u529b\u3068SQL\u3092\u8cbc\u308b\u3060\u3051\u3067\u3001\u539f\u56e0\u3068\u6539\u5584\u7b56\u3092Claude Code\u304c\u8fd4\u3057\u3066\u304f\u308c\u307e\u3059\u3002\u307e\u305a\u306f\u7121\u6599\u76f8\u8ac7\u3067\u304a\u6c17\u8efd\u306b\u3069\u3046\u305e\u3002<\/div>\n<\/div>\n\n\n\n<div style=\"background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);border-radius:16px;padding:36px 32px;margin:48px 0 16px;color:#fff;\">\n  <p style=\"font-size:13px;font-weight:700;color:#dc2626;letter-spacing:2px;margin:0 0 12px;\">NEXT STEP<\/p>\n  <p style=\"font-size:22px;font-weight:800;line-height:1.5;margin:0 0 20px;\">\u3053\u306e\u8a18\u4e8b\u306e\u5185\u5bb9\u3092\u3001\u3042\u306a\u305f\u306e\u30d3\u30b8\u30cd\u30b9\u3067<br>\u5b9f\u8df5\u3057\u3066\u307f\u307e\u305b\u3093\u304b\uff1f<\/p>\n  <div style=\"background:rgba(255,255,255,0.06);border:1px solid rgba(255,255,255,0.12);border-radius:12px;padding:24px;max-width:560px;margin:0 auto;\">\n    <p style=\"font-size:13px;color:#dc2626;font-weight:700;margin:0 0 8px;\">AI\u6d3b\u7528\u3092\u81ea\u793e\u3067\u56de\u305b\u308b\u3088\u3046\u306b\u306a\u308a\u305f\u3044\u65b9\u3078<\/p>\n    <p style=\"font-size:20px;font-weight:800;margin:0 0 12px;\">AI\u9b3c\u7ba1\u7406<\/p>\n    <p style=\"font-size:14px;color:rgba(255,255,255,0.75);margin:0 0 20px;line-height:1.7;\">Claude Code\u30fbCowork\u5c0e\u5165\u652f\u63f4\u304b\u3089\u696d\u52d9\u8a2d\u8a08\u30fb\u793e\u5185\u6d78\u900f\u307e\u3067\u5b9f\u8df5\u30d9\u30fc\u30b9\u3067\u4f34\u8d70\u3002\u300c\u81ea\u793e\u3067\u56de\u305b\u308b\u7d44\u7e54\u300d\u309290\u65e5\u3067\u4f5c\u308b\u7d4c\u55b6\u8005\u5411\u3051\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u3002<\/p>\n    <div style=\"text-align:center;\">\n      <a href=\"https:\/\/aikanri.genai-ai.co.jp\/?utm_source=blog&utm_medium=article&utm_campaign=cc-sql-in-clause&utm_content=next-step-cta\" target=\"_blank\" rel=\"noopener\" style=\"display:inline-block;background:#dc2626;color:#fff;font-weight:700;font-size:15px;padding:14px 32px;border-radius:30px;text-decoration:none;\">AI\u9b3c\u7ba1\u7406\u3092\u8a73\u3057\u304f\u898b\u308b \u2192<\/a>\n    <\/div>\n  <\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"faq\">\u3088\u304f\u3042\u308b\u8cea\u554f<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Q. SQL\u306eIN\u53e5\u3068\u306f\u4f55\u3067\u3059\u304b\uff1f\u3069\u3093\u306a\u6642\u306b\u4f7f\u3044\u307e\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A. IN\u53e5\u306fWHERE\u6761\u4ef6\u306e\u4e2d\u3067\u300c\u3053\u306e\u30ab\u30e9\u30e0\u306e\u5024\u304c\u3001\u6307\u5b9a\u3057\u305f\u30ea\u30b9\u30c8\u306e\u3044\u305a\u308c\u304b\u3068\u4e00\u81f4\u3059\u308b\u884c\u300d\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306e\u6f14\u7b97\u5b50\u3067\u3059\u3002\u4f8b\u3048\u3070WHERE prefecture IN ('\u6771\u4eac\u90fd', '\u5927\u962a\u5e9c', '\u795e\u5948\u5ddd\u770c')\u3068\u66f8\u304f\u3068\u3001prefecture\u304c\u6771\u4eac\u90fd\u30fb\u5927\u962a\u5e9c\u30fb\u795e\u5948\u5ddd\u770c\u306e\u3044\u305a\u308c\u304b\u306e\u884c\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002OR\u3092\u8907\u6570\u4e26\u3079\u308b\u3088\u308a\u7c21\u6f54\u3067\u8aad\u307f\u3084\u3059\u304f\u3001\u5024\u3092\u8ffd\u52a0\u30fb\u524a\u9664\u3057\u3084\u3059\u3044\u305f\u3081\u3001\u8907\u6570\u306e\u5024\u3067\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3059\u308b\u5834\u9762\u306b\u9069\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q. SQL\u306eIN\u53e5\u3068OR\u6f14\u7b97\u5b50\u306f\u4f55\u304c\u9055\u3044\u307e\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A. \u7d50\u679c\u306f\u540c\u3058\u3067\u3059\u304c\u53ef\u8aad\u6027\u3068\u4fdd\u5b88\u6027\u304c\u7570\u306a\u308a\u307e\u3059\u3002WHERE status_id IN (1, 2, 5) \u306fWHERE status_id = 1 OR status_id = 2 OR status_id = 5\u3068\u5b8c\u5168\u306b\u7b49\u4fa1\u3067\u3059\u3002IN\u53e5\u306e\u307b\u3046\u304c\u5024\u304c\u5897\u3048\u3066\u3082\u4e00\u884c\u306b\u307e\u3068\u307e\u3063\u3066\u8aad\u307f\u3084\u3059\u304f\u3001\u5024\u306e\u8ffd\u52a0\u30fb\u524a\u9664\u3082\u62ec\u5f27\u5185\u3092\u5909\u66f4\u3059\u308b\u3060\u3051\u3067\u6e08\u307f\u307e\u3059\u3002\u73fe\u4ee3\u306eRDBMS\u3067\u306f\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3082\u307b\u307c\u540c\u7b49\u3067\u3059\u30023\u3064\u4ee5\u4e0a\u306e\u5024\u3067\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3059\u308b\u5834\u5408\u306fIN\u53e5\u3092\u4f7f\u3046\u306e\u304c\u4e00\u822c\u7684\u306a\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q. NOT IN\u3092\u4f7f\u3063\u305f\u3089\u7d50\u679c\u304c0\u4ef6\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u306a\u305c\u3067\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A. NOT IN\u306e\u30ea\u30b9\u30c8\uff08\u307e\u305f\u306f\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u7d50\u679c\uff09\u306bNULL\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u306e\u304c\u539f\u56e0\u3067\u3059\u3002SQL\u306f3\u5024\u8ad6\u7406\uff08TRUE\/FALSE\/UNKNOWN\uff09\u3092\u4f7f\u3044\u3001NULL\u3068\u306e\u6bd4\u8f03\u306f\u5e38\u306bUNKNOWN\uff08\u771f\u3067\u3082\u507d\u3067\u3082\u306a\u3044\uff09\u3092\u8fd4\u3057\u307e\u3059\u3002NOT IN (1, 2, NULL) \u306f\u5185\u90e8\u7684\u306bcol != 1 AND col != 2 AND col != NULL\u3068\u8a55\u4fa1\u3055\u308c\u307e\u3059\u304c\u3001col != NULL\u304cUNKNOWN\u306e\u305f\u3081\u5168\u4f53\u304cUNKNOWN\u306b\u306a\u308a0\u4ef6\u304c\u8fd4\u308a\u307e\u3059\u3002\u5bfe\u7b56\u306fNOT EXISTS\u3092\u4f7f\u3046\u304b\u3001\u30b5\u30d6\u30af\u30a8\u30ea\u306bWHERE col IS NOT NULL\u3092\u8ffd\u52a0\u3057\u3066NULL\u3092\u9664\u5916\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q. IN\u53e5\u306e\u30b5\u30d6\u30af\u30a8\u30ea\u3068EXISTS\u3067\u306f\u3069\u3061\u3089\u304c\u901f\u3044\u3067\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A. MySQL 5.6\u4ee5\u964d\u3001PostgreSQL\u3001SQL Server\u306a\u3069\u306e\u73fe\u4ee3\u306eRDBMS\u3067\u306f\u30af\u30a8\u30ea\u30aa\u30d7\u30c6\u30a3\u30de\u30a4\u30b6\u304c\u81ea\u52d5\u6700\u9069\u5316\u3059\u308b\u305f\u3081\u3001\u307b\u307c\u540c\u7b49\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306b\u306a\u308b\u3053\u3068\u304c\u591a\u3044\u3067\u3059\u3002\u305f\u3060\u3057NULL\u306e\u5b89\u5168\u6027\u3068\u3044\u3046\u89b3\u70b9\u3067\u306f\u3001NOT IN\u306fNULL\u306b\u8106\u5f31\uff08\u5168\u4ef6\u30bc\u30ed\u306b\u306a\u308b\uff09\u306a\u305f\u3081NOT EXISTS\u3092\u63a8\u5968\u3057\u307e\u3059\u3002EXPLAIN\u3067\u5b9f\u884c\u8a08\u753b\u3092\u78ba\u8a8d\u3057\u3001type\u304cALL\u306e\u30d5\u30eb\u30b9\u30ad\u30e3\u30f3\u306b\u306a\u3063\u3066\u3044\u308b\u306a\u3089\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u8ffd\u52a0\u3059\u308b\u306e\u304c\u6700\u3082\u52b9\u679c\u7684\u306a\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6539\u5584\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q. IN\u53e5\u3092\u4f7f\u3046\u969b\u306b\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306f\u52b9\u304d\u307e\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A. \u306f\u3044\u3001IN\u53e5\u306e\u5bfe\u8c61\u30ab\u30e9\u30e0\u306b\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u304c\u3042\u308c\u3070\u52b9\u7387\u7684\u306b\u691c\u7d22\u3067\u304d\u307e\u3059\u3002EXPLAIN\u3092\u5b9f\u884c\u3057\u3066type=range\u304c\u8868\u793a\u3055\u308c\u308c\u3070\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f7f\u3063\u305f\u7bc4\u56f2\u30b9\u30ad\u30e3\u30f3\u304c\u884c\u308f\u308c\u3066\u3044\u307e\u3059\uff08type=ALL\u306f\u30d5\u30eb\u30b9\u30ad\u30e3\u30f3\u3067\u9045\u3044\uff09\u3002\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306fCREATE INDEX idx_name ON \u30c6\u30fc\u30d6\u30eb\u540d(\u30ab\u30e9\u30e0\u540d)\u3067\u4f5c\u6210\u3057\u307e\u3059\u3002\u305f\u3060\u3057IN\u53e5\u306e\u30ea\u30b9\u30c8\u304c\u975e\u5e38\u306b\u5927\u304d\u3044\uff08\u6570\u767e\u301c\u6570\u5343\u4ef6\u4ee5\u4e0a\uff09\u5834\u5408\u306f\u3001\u5bfe\u8c61ID\u3092\u4e00\u6642\u30c6\u30fc\u30d6\u30eb\u306b\u683c\u7d0d\u3057\u3066JOIN\u3059\u308b\u307b\u3046\u304c\u52b9\u7387\u7684\u306a\u30b1\u30fc\u30b9\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q. Claude Code\u3067SQL IN\u53e5\u3092\u4f7f\u3063\u305f\u30af\u30a8\u30ea\u3092\u4f5c\u3063\u3066\u3082\u3089\u3046\u306b\u306f\u3069\u3046\u4f1d\u3048\u308c\u3070\u3044\u3044\u3067\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A. \u30c6\u30fc\u30d6\u30eb\u540d\u30fb\u30ab\u30e9\u30e0\u540d\uff08CREATE TABLE\u6587\u304c\u3042\u308c\u3070\u305d\u306e\u307e\u307e\u8cbc\u308a\u4ed8\u3051\u308b\u3068\u78ba\u5b9f\uff09\u3068\u300c\u4f55\u3092\u53d6\u5f97\u3057\u305f\u3044\u304b\u300d\u3092\u65e5\u672c\u8a9e\u3067\u4f1d\u3048\u308b\u306e\u304c\u52b9\u679c\u7684\u3067\u3059\u3002\u4f8b: \u300corders\u30c6\u30fc\u30d6\u30eb\uff08order_id, customer_id, status_id, total_amount\uff09\u304b\u3089\u3001status_id\u304c1\u304b2\u306eorder_id, total_amount\u3092\u53d6\u5f97\u3059\u308bSQL\u3002total_amount\u306e\u9ad8\u3044\u9806\u306b\u30bd\u30fc\u30c8\u3002\u300d\u3068\u4f1d\u3048\u308b\u3068\u6b63\u78ba\u306aSQL\u304c\u8fd4\u3063\u3066\u304d\u307e\u3059\u3002NOT IN\u306eNULL\u554f\u984c\u304c\u5fc3\u914d\u306a\u5834\u5408\u306f\u300cNOT IN\u306f\u4f7f\u308f\u305aNOT EXISTS\u3067\u66f8\u3044\u3066\u300d\u3068\u660e\u793a\u3059\u308b\u3068\u5b89\u5168\u306aSQL\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"FAQPage\",\n  \"mainEntity\": [\n    {\n      \"@type\": \"Question\",\n      \"name\": \"SQL\u306eIN\u53e5\u3068\u306f\u4f55\u3067\u3059\u304b\uff1f\u3069\u3093\u306a\u6642\u306b\u4f7f\u3044\u307e\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"IN\u53e5\u306fWHERE\u6761\u4ef6\u306e\u4e2d\u3067\u300c\u3053\u306e\u30ab\u30e9\u30e0\u306e\u5024\u304c\u3001\u6307\u5b9a\u3057\u305f\u30ea\u30b9\u30c8\u306e\u3044\u305a\u308c\u304b\u3068\u4e00\u81f4\u3059\u308b\u884c\u300d\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306e\u6f14\u7b97\u5b50\u3067\u3059\u3002\u4f8b\u3048\u3070WHERE prefecture IN ('\u6771\u4eac\u90fd', '\u5927\u962a\u5e9c', '\u795e\u5948\u5ddd\u770c')\u3068\u66f8\u304f\u3068\u3001prefecture\u304c\u6771\u4eac\u90fd\u30fb\u5927\u962a\u5e9c\u30fb\u795e\u5948\u5ddd\u770c\u306e\u3044\u305a\u308c\u304b\u306e\u884c\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002OR\u3092\u8907\u6570\u4e26\u3079\u308b\u3088\u308a\u7c21\u6f54\u3067\u8aad\u307f\u3084\u3059\u304f\u3001\u5024\u3092\u8ffd\u52a0\u30fb\u524a\u9664\u3057\u3084\u3059\u3044\u305f\u3081\u3001\u8907\u6570\u306e\u5024\u3067\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3059\u308b\u5834\u9762\u306b\u9069\u3057\u3066\u3044\u307e\u3059\u3002\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"SQL\u306eIN\u53e5\u3068OR\u6f14\u7b97\u5b50\u306f\u4f55\u304c\u9055\u3044\u307e\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"\u7d50\u679c\u306f\u540c\u3058\u3067\u3059\u304c\u53ef\u8aad\u6027\u3068\u4fdd\u5b88\u6027\u304c\u7570\u306a\u308a\u307e\u3059\u3002WHERE status_id IN (1, 2, 5) \u306fWHERE status_id = 1 OR status_id = 2 OR status_id = 5\u3068\u5b8c\u5168\u306b\u7b49\u4fa1\u3067\u3059\u3002IN\u53e5\u306e\u307b\u3046\u304c\u5024\u304c\u5897\u3048\u3066\u3082\u4e00\u884c\u306b\u307e\u3068\u307e\u3063\u3066\u8aad\u307f\u3084\u3059\u304f\u3001\u5024\u306e\u8ffd\u52a0\u30fb\u524a\u9664\u3082\u62ec\u5f27\u5185\u3092\u5909\u66f4\u3059\u308b\u3060\u3051\u3067\u6e08\u307f\u307e\u3059\u3002\u73fe\u4ee3\u306eRDBMS\u3067\u306f\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3082\u307b\u307c\u540c\u7b49\u3067\u3059\u30023\u3064\u4ee5\u4e0a\u306e\u5024\u3067\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3059\u308b\u5834\u5408\u306fIN\u53e5\u3092\u4f7f\u3046\u306e\u304c\u4e00\u822c\u7684\u306a\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u3067\u3059\u3002\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"NOT IN\u3092\u4f7f\u3063\u305f\u3089\u7d50\u679c\u304c0\u4ef6\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u306a\u305c\u3067\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"NOT IN\u306e\u30ea\u30b9\u30c8\uff08\u307e\u305f\u306f\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u7d50\u679c\uff09\u306bNULL\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u306e\u304c\u539f\u56e0\u3067\u3059\u3002SQL\u306f3\u5024\u8ad6\u7406\uff08TRUE\/FALSE\/UNKNOWN\uff09\u3092\u4f7f\u3044\u3001NULL\u3068\u306e\u6bd4\u8f03\u306f\u5e38\u306bUNKNOWN\uff08\u771f\u3067\u3082\u507d\u3067\u3082\u306a\u3044\uff09\u3092\u8fd4\u3057\u307e\u3059\u3002NOT IN (1, 2, NULL) \u306f\u5185\u90e8\u7684\u306bcol != 1 AND col != 2 AND col != NULL\u3068\u8a55\u4fa1\u3055\u308c\u307e\u3059\u304c\u3001col != NULL\u304cUNKNOWN\u306e\u305f\u3081\u5168\u4f53\u304cUNKNOWN\u306b\u306a\u308a0\u4ef6\u304c\u8fd4\u308a\u307e\u3059\u3002\u5bfe\u7b56\u306fNOT EXISTS\u3092\u4f7f\u3046\u304b\u3001\u30b5\u30d6\u30af\u30a8\u30ea\u306bWHERE col IS NOT NULL\u3092\u8ffd\u52a0\u3057\u3066NULL\u3092\u9664\u5916\u3059\u308b\u3053\u3068\u3067\u3059\u3002\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"IN\u53e5\u306e\u30b5\u30d6\u30af\u30a8\u30ea\u3068EXISTS\u3067\u306f\u3069\u3061\u3089\u304c\u901f\u3044\u3067\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"MySQL 5.6\u4ee5\u964d\u3001PostgreSQL\u3001SQL Server\u306a\u3069\u306e\u73fe\u4ee3\u306eRDBMS\u3067\u306f\u30af\u30a8\u30ea\u30aa\u30d7\u30c6\u30a3\u30de\u30a4\u30b6\u304c\u81ea\u52d5\u6700\u9069\u5316\u3059\u308b\u305f\u3081\u3001\u307b\u307c\u540c\u7b49\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306b\u306a\u308b\u3053\u3068\u304c\u591a\u3044\u3067\u3059\u3002\u305f\u3060\u3057NULL\u306e\u5b89\u5168\u6027\u3068\u3044\u3046\u89b3\u70b9\u3067\u306f\u3001NOT IN\u306fNULL\u306b\u8106\u5f31\uff08\u5168\u4ef6\u30bc\u30ed\u306b\u306a\u308b\uff09\u306a\u305f\u3081NOT EXISTS\u3092\u63a8\u5968\u3057\u307e\u3059\u3002EXPLAIN\u3067\u5b9f\u884c\u8a08\u753b\u3092\u78ba\u8a8d\u3057\u3001type\u304cALL\u306e\u30d5\u30eb\u30b9\u30ad\u30e3\u30f3\u306b\u306a\u3063\u3066\u3044\u308b\u306a\u3089\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u8ffd\u52a0\u3059\u308b\u306e\u304c\u6700\u3082\u52b9\u679c\u7684\u306a\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6539\u5584\u3067\u3059\u3002\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"IN\u53e5\u3092\u4f7f\u3046\u969b\u306b\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306f\u52b9\u304d\u307e\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"\u306f\u3044\u3001IN\u53e5\u306e\u5bfe\u8c61\u30ab\u30e9\u30e0\u306b\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u304c\u3042\u308c\u3070\u52b9\u7387\u7684\u306b\u691c\u7d22\u3067\u304d\u307e\u3059\u3002EXPLAIN\u3092\u5b9f\u884c\u3057\u3066type=range\u304c\u8868\u793a\u3055\u308c\u308c\u3070\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f7f\u3063\u305f\u7bc4\u56f2\u30b9\u30ad\u30e3\u30f3\u304c\u884c\u308f\u308c\u3066\u3044\u307e\u3059\uff08type=ALL\u306f\u30d5\u30eb\u30b9\u30ad\u30e3\u30f3\u3067\u9045\u3044\uff09\u3002\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306fCREATE INDEX idx_name ON \u30c6\u30fc\u30d6\u30eb\u540d(\u30ab\u30e9\u30e0\u540d)\u3067\u4f5c\u6210\u3057\u307e\u3059\u3002\u305f\u3060\u3057IN\u53e5\u306e\u30ea\u30b9\u30c8\u304c\u975e\u5e38\u306b\u5927\u304d\u3044\uff08\u6570\u767e\u301c\u6570\u5343\u4ef6\u4ee5\u4e0a\uff09\u5834\u5408\u306f\u3001\u5bfe\u8c61ID\u3092\u4e00\u6642\u30c6\u30fc\u30d6\u30eb\u306b\u683c\u7d0d\u3057\u3066JOIN\u3059\u308b\u307b\u3046\u304c\u52b9\u7387\u7684\u306a\u30b1\u30fc\u30b9\u3082\u3042\u308a\u307e\u3059\u3002\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"Claude Code\u3067SQL IN\u53e5\u3092\u4f7f\u3063\u305f\u30af\u30a8\u30ea\u3092\u4f5c\u3063\u3066\u3082\u3089\u3046\u306b\u306f\u3069\u3046\u4f1d\u3048\u308c\u3070\u3044\u3044\u3067\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"\u30c6\u30fc\u30d6\u30eb\u540d\u30fb\u30ab\u30e9\u30e0\u540d\uff08CREATE TABLE\u6587\u304c\u3042\u308c\u3070\u305d\u306e\u307e\u307e\u8cbc\u308a\u4ed8\u3051\u308b\u3068\u78ba\u5b9f\uff09\u3068\u300c\u4f55\u3092\u53d6\u5f97\u3057\u305f\u3044\u304b\u300d\u3092\u65e5\u672c\u8a9e\u3067\u4f1d\u3048\u308b\u306e\u304c\u52b9\u679c\u7684\u3067\u3059\u3002\u4f8b: \u300corders\u30c6\u30fc\u30d6\u30eb\uff08order_id, customer_id, status_id, total_amount\uff09\u304b\u3089\u3001status_id\u304c1\u304b2\u306eorder_id, total_amount\u3092\u53d6\u5f97\u3059\u308bSQL\u3002total_amount\u306e\u9ad8\u3044\u9806\u306b\u30bd\u30fc\u30c8\u3002\u300d\u3068\u4f1d\u3048\u308b\u3068\u6b63\u78ba\u306aSQL\u304c\u8fd4\u3063\u3066\u304d\u307e\u3059\u3002NOT IN\u306eNULL\u554f\u984c\u304c\u5fc3\u914d\u306a\u5834\u5408\u306f\u300cNOT IN\u306f\u4f7f\u308f\u305aNOT EXISTS\u3067\u66f8\u3044\u3066\u300d\u3068\u660e\u793a\u3059\u308b\u3068\u5b89\u5168\u306aSQL\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002\"\n      }\n    }\n  ]\n}\n<\/script>\n\n\n","protected":false},"excerpt":{"rendered":"<p>SQL\u306eIN\u53e5\u3092\u5b8c\u5168\u89e3\u8aac\u3002\u57fa\u672c\u7684\u306aIN\u53e5\u306e\u4f7f\u3044\u65b9\u3001NOT IN\u3001IN\u53e5\u3068OR\u306e\u9055\u3044\u3001\u30b5\u30d6\u30af\u30a8\u30ea\u3068\u306e\u7d44\u307f\u5408\u308f\u305b\u3001EXISTS\u3068\u306e\u6027\u80fd\u6bd4\u8f03\u3001NULL\u304c\u542b\u307e\u308c\u308b\u5834\u5408\u306e\u843d\u3068\u3057\u7a74\u3001Claude Code\u3067\u306eSQL\u81ea\u52d5\u751f\u6210\u307e\u3067\u5b9f\u4f8b\u4ed8\u304d\u3067\u7db2\u7f85\u3002<\/p>\n","protected":false},"author":1,"featured_media":18452,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"sitemap_hide":"","_veu_custom_css":"","vkexunit_cta_each_option":"","footnotes":"","rank_math_description":"SQL\u306eIN\u53e5\u3092\u5b8c\u5168\u89e3\u8aac\u3002\u57fa\u672c\u7684\u306aIN\u53e5\u306e\u4f7f\u3044\u65b9\u3001NOT IN\u3001IN\u53e5\u3068OR\u306e\u9055\u3044\u3001\u30b5\u30d6\u30af\u30a8\u30ea\u3068\u306e\u7d44\u307f\u5408\u308f\u305b\u3001EXISTS\u3068\u306e\u6027\u80fd\u6bd4\u8f03\u3001NULL\u304c\u542b\u307e\u308c\u308b\u5834\u5408\u306e\u843d\u3068\u3057\u7a74\u3001Claude Code\u3067\u306eSQL\u81ea\u52d5\u751f\u6210\u307e\u3067\u5b9f\u4f8b\u4ed8\u304d\u3067\u7db2\u7f85\u3002","rank_math_focus_keyword":"SQL IN\u53e5 \u4f7f\u3044\u65b9 \u30b5\u30d6\u30af\u30a8\u30ea","rank_math_title":"\u30102026\u5e747\u6708\u6700\u65b0\u3011SQL IN\u53e5\u5b8c\u5168\u30ac\u30a4\u30c9\uff5c\u57fa\u672c\u30fbNOT IN\u30fb\u30b5\u30d6\u30af\u30a8\u30ea\u30fbEXISTS\u3068\u306e\u6bd4\u8f03\u30fbClaude Co\uff5cAI\u9b3c\u7ba1\u7406","pending_rewrite_html":"","pending_rewrite_id":"","pending_rewrite_kw":"","pending_rewrite_at":"","pending_rewrite_source":"","pending_rewrite_brief":"","pending_rewrite_evidence":"","approved_rewrite_html":"","approved_rewrite_id":"","approved_rewrite_kw":"","approved_rewrite_at":"","approved_rewrite_by":"","approved_rewrite_brief":"","approved_rewrite_evidence":"","rewrite_tracker_baseline":"","rewrite_tracker_7day":"","rewrite_tracker_14day":"","rewrite_tracker_30day":"","rewrite_tracker_notified":""},"categories":[3,2],"tags":[],"class_list":["post-18453","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai-automation","category-claude-tips"],"_links":{"self":[{"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/posts\/18453","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/comments?post=18453"}],"version-history":[{"count":2,"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/posts\/18453\/revisions"}],"predecessor-version":[{"id":18455,"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/posts\/18453\/revisions\/18455"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/media\/18452"}],"wp:attachment":[{"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/media?parent=18453"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/categories?post=18453"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/tags?post=18453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}