{"id":3846,"date":"2022-12-24T12:00:36","date_gmt":"2022-12-24T03:00:36","guid":{"rendered":"https:\/\/www.bold.ne.jp\/engineer-club\/?p=3846"},"modified":"2025-11-19T10:47:50","modified_gmt":"2025-11-19T01:47:50","slug":"sql-not-in","status":"publish","type":"post","link":"https:\/\/www.bold.ne.jp\/engineer-club\/sql-not-in","title":{"rendered":"SQL\u306eNOT IN\u53e5\u3068\u306f\uff1f\u6307\u5b9a\u3057\u305f\u8907\u6570\u306e\u5024\u306b\u8a72\u5f53\u3057\u306a\u3044\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308bNOT IN\u53e5\u306e\u4f7f\u3044\u65b9"},"content":{"rendered":"<p>NOT IN\u53e5\u306f\u3001<strong>\u6307\u5b9a\u3057\u305f\u8907\u6570\u306e\u5024\u306b\u8a72\u5f53\u3057\u306a\u3044\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u969b\u306b\u4f7f\u7528\u3059\u308b<\/strong>\u547d\u4ee4\u3067\u3059\u3002<\/p>\n<p>\u672c\u8a18\u4e8b\u3067\u306f\u3001<span>NOT IN<\/span>\u53e5\u3068\u306f\u4f55\u304b\u3001\u307e\u305f\u3001<span>NOT IN<\/span>\u53e5\u306e<span style=\"text-decoration: underline;\">\u5177\u4f53\u7684\u306a\u4f7f\u3044\u65b9<\/span>\u3001<span>NOT IN<\/span>\u53e5<span style=\"text-decoration: underline;\">\u4f7f\u7528\u6642\u306e\u6ce8\u610f\u70b9<\/span>\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">\u76ee\u6b21<\/p><ul class=\"toc_list\"><li><a href=\"#SQLNOT_IN\">\uff11\uff0eSQL\u306eNOT IN\u53e5\u3068\u306f<\/a><\/li><li><a href=\"#SQL_NOT_IN\">\uff12\uff0eSQL NOT IN\u53e5\u306e\u4f7f\u3044\u65b9<\/a><\/li><li><a href=\"#NOT_IN\">\uff13\uff0eNOT IN\u53e5\u4f7f\u7528\u6642\u306e\u6ce8\u610f\u70b9<\/a><ul><li><a href=\"#null\">\u30fb\u6307\u5b9a\u3057\u305f\u8907\u6570\u306e\u5024\u306bnull\u304c\u542b\u307e\u308c\u308b\u5834\u5408<\/a><\/li><li><a href=\"#NOT_IN-2\">\u30fbNOT IN\u53e5\u4f7f\u7528\u6642\u306e\u51e6\u7406\u901f\u5ea6\u306b\u3064\u3044\u3066<\/a><\/li><\/ul><\/li><li><a href=\"#i\">\uff14\uff0e\u307e\u3068\u3081<\/a><\/li><\/ul><\/div>\n<h2><span id=\"SQLNOT_IN\">\uff11\uff0eSQL\u306eNOT IN\u53e5\u3068\u306f<\/span><\/h2>\n<p>NOT IN\u53e5\u306f\u3001\u6307\u5b9a\u3057\u305f\u8907\u6570\u306e\u5024\u306b\u8a72\u5f53\u3057\u306a\u3044\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u969b\u306b\u4f7f\u7528\u3059\u308b\u30af\u30a8\u30ea\u3067\u3059\u3002<\/p>\n<p>IN\u53e5\u3068<span>NOT IN<\/span>\u53e5\u3069\u3061\u3089\u3082\u3001\u4e3b\u306b\u8907\u6570\u306e\u6761\u4ef6\u3092\u6307\u5b9a\u3057\u3066\u691c\u7d22\u3092\u884c\u3046\u5834\u5408\u306b\u4f7f\u7528\u3059\u308b\u30af\u30a8\u30ea\u3067\u3059\u304c\u3001IN\u53e5\u304c\u6307\u5b9a\u3057\u305f\u8907\u6570\u306e\u5024\u306b<strong><u>\u8a72\u5f53\u3059\u308b<\/u><\/strong>\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u969b\u306b\u4f7f\u7528\u3059\u308b\u30af\u30a8\u30ea\u3067\u3042\u308b\u306e\u306b\u5bfe\u3057\u3001NOT IN\u53e5\u306f\u6307\u5b9a\u3057\u305f\u8907\u6570\u306e\u5024\u306b<strong><u>\u8a72\u5f53\u3057\u306a\u3044<\/u><\/strong>\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u969b\u306b\u4f7f\u7528\u3059\u308b\u30af\u30a8\u30ea\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>SQL\u3067\u6307\u5b9a\u3057\u305f\u8907\u6570\u306e\u5024\u306b<strong><u>\u8a72\u5f53\u3057\u306a\u3044<\/u><\/strong>\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u969b\u3001<span>NOT IN<\/span>\u53e5\u3092\u4f7f\u7528\u305b\u305a\u306b\u30c7\u30fc\u30bf\u62bd\u51fa\u3059\u308b\u5834\u5408\u3001\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u901a\u308a\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4f8b\uff09\u30e6\u30fc\u30b6\u30fc<span>(user)<\/span>\u30c6\u30fc\u30d6\u30eb\u306e\u4e2d\u304b\u3089\u540d\u524d<span>(name)<\/span>\u304c\u300c\u5c71\u7530\u300d\u304b\u300c\u4f50\u85e4\u300d\u3092\u542b\u307e\u306a\u3044\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408<\/p>\n<pre class=\"prettyprint lang:default decode:true\">SELECT * FROM user WHERE NOT (name = \u201b\u5c71\u7530\u201b OR name = \u201b\u4f50\u85e4\u201b);<\/pre>\n<p>\u3053\u308c\u3067\u3082\u5bfe\u8c61\u306e\u30c7\u30fc\u30bf\u306f\u62bd\u51fa\u3067\u304d\u307e\u3059\u304c\u3001\u6307\u5b9a\u3059\u308b\u8981\u7d20\u6570\u304c\u5897\u3048\u308b\u306b\u3064\u308c\u6761\u4ef6\u6587\u304c\u5197\u9577\u5316\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u3053\u3053\u3067\u8907\u6570\u306e\u6761\u4ef6\u6307\u5b9a\u3092\u3088\u308a\u77ed\u3044\u6761\u4ef6\u6587\u3067\u307e\u3068\u3081\u3066\u884c\u3046\u305f\u3081\u306b\u7528\u3044\u308b\u306e\u304c<span>NOT IN<\/span>\u53e5\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2><span id=\"SQL_NOT_IN\">\uff12\uff0eSQL NOT IN\u53e5\u306e\u4f7f\u3044\u65b9<\/span><\/h2>\n<p>\u305d\u308c\u3067\u306f\u5b9f\u969b\u306b<span>NOT IN<\/span>\u53e5\u3092\u4f7f\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<span>SQL<\/span>\u3067\u6307\u5b9a\u3057\u305f\u8907\u6570\u306e\u5024\u306b<strong><u>\u8a72\u5f53\u3057\u306a\u3044<\/u><\/strong>\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u969b\u3001<span>NOT IN<\/span>\u53e5\u3092\u4f7f\u7528\u3057\u3066\u30c7\u30fc\u30bf\u62bd\u51fa\u3059\u308b\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u901a\u308a\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4f8b\uff09\u30e6\u30fc\u30b6\u30fc<span>(user)<\/span>\u30c6\u30fc\u30d6\u30eb\u306e\u4e2d\u304b\u3089\u540d\u524d<span>(name)<\/span>\u304c\u300c\u5c71\u7530\u300d\u304b\u300c\u4f50\u85e4\u300d\u3092\u542b\u307e\u306a\u3044\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408<span>[NOT IN<\/span>\u53e5\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408<span>]<\/span><\/p>\n<pre class=\"prettyprint lang:default decode:true\">SELECT * FROM user WHERE name NOT IN(\u201b\u5c71\u7530\u201b, \u201b\u4f50\u85e4\u201b);<\/pre>\n<p>\u4e0a\u8a18\u306e\u901a\u308a\u3001<span>NOT IN<\/span>\u53e5\u3092\u4f7f\u7528\u3057\u306a\u3044\u5834\u5408\u3068\u6bd4\u8f03\u3059\u308b\u3068\u3001\u6761\u4ef6\u6587\u304c\u77ed\u304f\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u300c<span>&#8220;<\/span>\u5c71\u7530<span>&#8220;, &#8220;<\/span>\u4f50\u85e4<span>&#8220;, &#8220;<\/span>\u7530\u4e2d<span>&#8220;&#8230;<\/span>\u300d\u3068\u6307\u5b9a\u3059\u308b\u8981\u7d20\u6570\u304c\u5897\u3048\u308b\u306b\u3064\u308c\u3001<span>NOT IN<\/span>\u53e5\u3092\u4f7f\u7528\u3057\u306a\u3044\u5834\u5408\u3068\u6bd4\u8f03\u3057\u305f\u6642\u306e\u6761\u4ef6\u6587\u306e\u77ed\u3055\u306f\u3088\u308a\u9855\u8457\u306b\u306a\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h2><span id=\"NOT_IN\">\uff13\uff0eNOT IN\u53e5\u4f7f\u7528\u6642\u306e\u6ce8\u610f\u70b9<\/span><\/h2>\n<p>NOT IN\u53e5\u3092\u4f7f\u7528\u3059\u308b\u969b\u3001\u6ce8\u610f\u3059\u3079\u304d\u70b9\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h3><span id=\"null\"><span class=\"f-marker-p\">\u30fb\u6307\u5b9a\u3057\u305f\u8907\u6570\u306e\u5024\u306b<span>null<\/span>\u304c\u542b\u307e\u308c\u308b\u5834\u5408<\/span><\/span><\/h3>\n<p>\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30af\u30a8\u30ea\u3092\u5b9f\u884c\u3057\u305f\u3068\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">SELECT * FROM user WHERE name NOT IN(\u201b\u5c71\u7530\u201b, \u201b\u4f50\u85e4\u201b, null);<\/pre>\n<p>\u4e0a\u8a18\u306e\u30af\u30a8\u30ea\u5b9f\u884c\u7d50\u679c\u3068\u3057\u3066\u3001<span>name<\/span>\u30ab\u30e9\u30e0\u306b\u304a\u3044\u3066\u3001\u300c\u5c71\u7530\u300d\u3068\u300c\u4f50\u85e4\u300d\u3092\u542b\u307e\u306a\u3044\u3001\u307e\u305f\u3001<span>null<\/span>\u3067\u306f\u306a\u3044\u30c7\u30fc\u30bf\u304c\u53d6\u5f97\u3067\u304d\u305d\u3046\u306b\u601d\u3048\u307e\u3059\u304c\u3001\u5b9f\u969b\u306e\u7d50\u679c\u3068\u3057\u3066\u306f\u4f55\u3082\u53d6\u5f97\u3067\u304d\u307e\u305b\u3093\u3002NOT IN\u53e5\u3067\u6307\u5b9a\u3057\u305f\u5024\u306b<span>null<\/span>\u304c\u542b\u307e\u308c\u308b\u5834\u5408\u3001\u4f55\u3082\u53d6\u5f97\u3067\u304d\u306a\u304f\u306a\u308b\u3068\u3044\u3046\u3053\u3068\u3092\u899a\u3048\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h3><span id=\"NOT_IN-2\"><span class=\"f-marker-p\">\u30fb<span>NOT IN<\/span>\u53e5\u4f7f\u7528\u6642\u306e\u51e6\u7406\u901f\u5ea6\u306b\u3064\u3044\u3066<\/span><\/span><\/h3>\n<p>\u3082\u3046\u4e00\u5ea6<span>NOT IN<\/span>\u53e5\u3092\u4f7f\u7528\u3057\u305f\u5834\u5408\u306e\u30af\u30a8\u30ea\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u4f8b\uff09\u30e6\u30fc\u30b6\u30fc<span>(user)<\/span>\u30c6\u30fc\u30d6\u30eb\u306e\u4e2d\u304b\u3089\u540d\u524d<span>(name)<\/span>\u304c\u300c\u5c71\u7530\u300d\u304b\u300c\u4f50\u85e4\u300d\u3092\u542b\u307e\u306a\u3044\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408<span>[NOT IN<\/span>\u53e5\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408<span>]<\/span><\/p>\n<pre class=\"prettyprint lang:default decode:true\">SELECT * FROM user WHERE name NOT IN(\u201b\u5c71\u7530\u201b, \u201b\u4f50\u85e4\u201b);<\/pre>\n<p>\u4e0a\u8a18\u306e\u4f8b\u3067\u306f\u3001\u300c\u5c71\u7530\u300d\u3068\u300c\u4f50\u85e4\u300d\u3092\u542b\u307e\u306a\u3044\u30ec\u30b3\u30fc\u30c9\u5168\u3066\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3068\u306a\u308a\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u81a8\u5927\u306a\u30ec\u30b3\u30fc\u30c9\u6570\u3092\u7ba1\u7406\u3057\u3066\u3044\u308b\u72b6\u6cc1\u4e0b\u3067\u306f\u3001<span>NOT IN<\/span>\u53e5\u3092\u7528\u3044\u305f\u51e6\u7406\u306f\u91cd\u305f\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u3053\u308c\u306f\u5185\u90e8\u3067\u30c7\u30fc\u30bf\u306e\u5168\u691c\u7d22\u3092\u884c\u3063\u3066\u3044\u308b\u305f\u3081\u3067\u3059\u3002<\/p>\n<p>\u30ec\u30b3\u30fc\u30c9\u6570\u304c\u591a\u3044\u4e2d\u3067<span>NOT IN<\/span>\u53e5\u3092\u4f7f\u7528\u3059\u308b\u969b\u306f\u3053\u3046\u3057\u305f\u70b9\u306b\u6ce8\u610f\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2><span id=\"i\">\uff14\uff0e\u307e\u3068\u3081<\/span><\/h2>\n<p>\u4ee5\u4e0a\u3001<span>NOT IN<\/span>\u53e5\u3068\u306f\u4f55\u304b\u3001\u307e\u305f\u3001<span>NOT IN<\/span>\u53e5\u306e\u5177\u4f53\u7684\u306a\u4f7f\u3044\u65b9\u3001<span>NOT IN<\/span>\u53e5\u4f7f\u7528\u6642\u306e\u6ce8\u610f\u70b9\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u3066\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u6307\u5b9a\u3057\u305f\u8907\u6570\u306e\u5024\u306b<strong><u>\u8a72\u5f53\u3057\u306a\u3044<\/u><\/strong>\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u969b\u306f\u662f\u975e\u4f7f\u3063\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\"><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>NOT IN\u53e5\u306f\u3001\u6307\u5b9a\u3057\u305f\u8907\u6570\u306e\u5024\u306b\u8a72\u5f53\u3057\u306a\u3044\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u969b\u306b\u4f7f\u7528\u3059\u308b\u547d\u4ee4\u3067\u3059\u3002 \u672c\u8a18\u4e8b\u3067\u306f\u3001NOT IN\u53e5\u3068\u306f\u4f55\u304b\u3001\u307e\u305f\u3001NOT IN\u53e5\u306e\u5177\u4f53\u7684\u306a\u4f7f\u3044\u65b9\u3001NOT IN\u53e5\u4f7f\u7528\u6642\u306e\u6ce8\u610f\u70b9\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002 \u76ee\u6b21\uff11\uff0eS [&hellip;]<\/p>\n","protected":false},"author":21,"featured_media":3849,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[17],"acf":[],"_links":{"self":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/3846"}],"collection":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/comments?post=3846"}],"version-history":[{"count":6,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/3846\/revisions"}],"predecessor-version":[{"id":6110,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/3846\/revisions\/6110"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/media\/3849"}],"wp:attachment":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/media?parent=3846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/categories?post=3846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}