{"id":4743,"date":"2018-06-21T11:07:16","date_gmt":"2018-06-21T02:07:16","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=4743"},"modified":"2023-05-27T23:18:52","modified_gmt":"2023-05-27T14:18:52","slug":"%e3%80%90sql%e3%80%91%e3%80%8c%e8%bf%b0%e8%aa%9e%e3%80%8dbetween%e3%80%81in%e7%ad%89%e3%81%ae%e7%a8%ae%e9%a1%9e","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=4743","title":{"rendered":"\u3010SQL\u3011\u300c\u8ff0\u8a9e\u300d(BETWEEN\u3001IN\u3001EXISTS\u7b49)\u306e\u7a2e\u985e"},"content":{"rendered":"<h2>\u8ff0\u8a9e\u3068\u306f\uff1f<\/h2>\n<p>&lt;&gt;\u3084\u3001BETWEEN\u7b49\u306eSQL\u306e\u4e2d\u306e\u3001<span style=\"color: #ff0000;\"><strong>\u4e88\u7d04\u8a9e\u306e\u3088\u3046\u306a\u5b58\u5728\u306e\u3053\u3068<\/strong><\/span>\u3067\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001NVL\u3084\u3001DECODE\u7b49\u306e\u95a2\u6570\u3068\u306f\u307e\u305f\u9055\u3063\u305f\u5b58\u5728\u306b\u306a\u308a\u307e\u3059\u3002\u3088\u304f\u4f7f\u308f\u308c\u308b\u306e\u306fIN\u3084EXIST\u3001NOT NULL\u306a\u3069\u3067\u3057\u3087\u3046\u3002<\/p>\n<h2>\u95a2\u6570\u3068\u306e\u9055\u3044<\/h2>\n<p>\u8ff0\u8a9e\u306f\u5f15\u6570\u3092\u53d6\u3063\u3066\u3001\u5024\u3082\u8fd4\u3057\u307e\u3059\u304c\u3001\u95a2\u6570\u3068\u306f\u533a\u5225\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u305d\u306e\u9055\u3044\u306f\u4f55\u304b\u3068\u3044\u3046\u3068\u3001<span style=\"color: #ff0000;\"><strong>\u623b\u308a\u5024\u304c\u5fc5\u305a\u771f\u507d\u5024(true\/false\/unknown)\u306b\u306a\u308b\u3053\u3068<\/strong><\/span>\u3067\u3059\u3002<\/p>\n<h2>\u8ff0\u8a9e\u4e00\u89a7<\/h2>\n<table>\n<tbody>\n<tr>\n<th width=\"150\">\u8ff0\u8a9e\u540d<\/th>\n<th>\u8aac\u660e<\/th>\n<\/tr>\n<tr>\n<td>=<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>&lt;&gt;<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>&lt;<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>&gt;<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>BETWEEN<\/td>\n<td>xxx\u304b\u3089yyy\u306e\u9593\u306e\u691c\u7d22\u304c\u3067\u304d\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td>LIKE<\/td>\n<td>\u3042\u3044\u307e\u3044\u691c\u7d22\uff08\u90e8\u5206\u4e00\u81f4\u691c\u7d22\uff09\u3092\u884c\u3044\u305f\u3044\u5834\u5408\u306b\u4f7f\u3044\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td>NOT IS NULL<\/td>\n<td>NULL\u4ee5\u5916\u3092\u62bd\u51fa\u3067\u304d\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td>IS NULL<\/td>\n<td>NULL\u3092\u62bd\u51fa\u3067\u304d\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td>IN<\/td>\n<td>\u300cOR\u30ad\u30fc\u30ef\u30fc\u30c9\u300d\u3092\u7c21\u7565\u5316\u3059\u308b\u76ee\u7684\u3067\u4f7f\u308f\u308c\u307e\u3059\u3002\u30b5\u30d6\u30af\u30a8\u30ea\u3082\u5f15\u6570\u306b\u53d6\u308c\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td>NOT IN<\/td>\n<td>\u300cOR\u30ad\u30fc\u30ef\u30fc\u30c9\u300d\u3092\u7c21\u7565\u5316\u3059\u308b\u76ee\u7684\u3067\u4f7f\u308f\u308c\u307e\u3059\u3002\u30b5\u30d6\u30af\u30a8\u30ea\u3092\u5f15\u6570\u306b\u53d6\u308c\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td>EXISTS<\/td>\n<td>\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea\u304c\u552f\u4e00\u306e\u5f15\u6570\u306b\u306a\u308a\u307e\u3059\u3002<span style=\"color: #ff0000;\"><strong>\u5b58\u5728\u3059\u308b\u30c7\u30fc\u30bf<\/strong><strong>\u306e\u307f<\/strong><\/span>\u306b\u3064\u3044\u3066\u691c\u7d22\u3092\u304b\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/td>\n<\/tr>\n<tr>\n<td>NOT EXISTS<\/td>\n<td>\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea\u304c\u552f\u4e00\u306e\u5f15\u6570\u306b\u306a\u308a\u307e\u3059\u3002<span style=\"color: #ff0000;\"><strong>\u5b58\u5728\u3057\u306a\u3044\u30c7\u30fc\u30bf\u306e\u307f<\/strong><\/span>\u306b\u3064\u3044\u3066\u691c\u7d22\u3092\u304b\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>BETWEEN<\/h2>\n<p>\u4ee5\u4e0b\u306f\u3001id\u304c1\u301c3\u306e\u9593\u306e\u30e6\u30fc\u30b6\u30fc\u3092\u53d6\u5f97\u3059\u308bSELECT\u6587\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">SELECT * FROM user WHERE id BETWEEN 1 AND 3;<\/pre>\n<h2>EXISTS\u8ff0\u8a9e\u306b\u3064\u3044\u3066<\/h2>\n<h3>\u7279\u5fb4<\/h3>\n<ul>\n<li>IN\u53e5\u306b\u3088\u3063\u3066\u3001\u4ee3\u7528\u3067\u304d\u308b\u306e\u3067\u3042\u307e\u308a\u4f7f\u308f\u308c\u306a\u3044\u304c\u3001\u4f7f\u3044\u3053\u306a\u305b\u308b\u3088\u3046\u306b\u306a\u308b\u3068\u91cd\u5b9d\u3059\u308b\u3002<\/li>\n<li>\u5f15\u6570\u3092<span style=\"color: #ff0000;\"><strong>\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea<\/strong><\/span>\u306e\u4e00\u3064\u3057\u304b\u53d6\u3089\u306a\u3044\u8ff0\u8a9e<\/li>\n<li>\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u623b\u308a\u5024\u306f\u8ad6\u7406\u5024(TRUE\/FALSE)\u3092\u8fd4\u3059\u3002<\/li>\n<\/ul>\n<h3>\u5f15\u6570\u3092\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u4e00\u3064\u3057\u304b\u53d6\u3089\u306a\u3044<\/h3>\n<p><span style=\"color: #ff0000;\"><strong>\u300c\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea\u300d<\/strong><\/span>\u306b\u3064\u3044\u3066\u306f\u3001\u4e0b\u8a18\u306e\u8a18\u4e8b\u3067\u89e3\u8aac\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"XxWtcsNpzN\"><p><a href=\"http:\/\/www.code-magagine.com\/?p=4736\">\u3010SQL\u3011\u300c\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea\u300d\u3068\u306f\u4f55\u304b\uff1f\u3001\u7d50\u5408\u3068\u306e\u4f7f\u3044\u5206\u3051\u306a\u3069\u3082<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"http:\/\/www.code-magagine.com\/?p=4736&#038;embed=true#?secret=XxWtcsNpzN\" data-secret=\"XxWtcsNpzN\" width=\"500\" height=\"282\" title=\"&#8220;\u3010SQL\u3011\u300c\u76f8\u95a2\u30b5\u30d6\u30af\u30a8\u30ea\u300d\u3068\u306f\u4f55\u304b\uff1f\u3001\u7d50\u5408\u3068\u306e\u4f7f\u3044\u5206\u3051\u306a\u3069\u3082&#8221; &#8212; \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30de\u30ac\u30b8\u30f3\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<h3>\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u623b\u308a\u5024\u306f\u8ad6\u7406\u5024(TRUE\/FALSE)\u3092\u8fd4\u3059\u3002<\/h3>\n<p>\u4f8b\u3048\u3070\u3001EXISTS\u8ff0\u8a9e\u3092\u4f7f\u3063\u305f\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30b5\u30d6\u30af\u30a8\u30ea\u306e\u5834\u5408\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u30b5\u30d6\u30af\u30a8\u30ea\u5185\u306e\u7d50\u679c\u306f\u30ec\u30b3\u30fc\u30c9\u306e\u3042\u308b\u306a\u3057\u3067\u3001TRUE\u3001FALSE\u3067\u8fd4\u3057\u3066\u305d\u306e\u7d50\u679c\u3092\u5143\u306b\u3001\u5224\u5b9a\u3057\u307e\u3059\u3002<\/strong><\/span><\/p>\n<pre class=\"lang:default decode:true\">SELECT * FROM USER_MASTER A\r\nWHERE EXISTS (SELECT * FROM AUTHORIZATION B WHERE A.USER_ID = B.USER_ID )<\/pre>\n<p>\u307e\u305f\u3001\u30b5\u30d6\u30af\u30a8\u30ea\u5185\u306e\u53d6\u5f97\u5217\u306b\u95a2\u3057\u3066\u306f\u3001\u57fa\u672c\u7684\u306b\u3069\u3093\u306a\u5217\u3067\u3082\u554f\u984c\u306a\u3044\u3067\u3059\u304c\u3001<span style=\"color: #ff0000;\"><strong>\u300cSELECT *\u300d<\/strong><\/span>\u3068\u3059\u308b\u3053\u3068\u304c\u6c7a\u307e\u308a\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8ff0\u8a9e\u3068\u306f\uff1f &lt;&gt;\u3084\u3001BETWEEN\u7b49\u306eSQL\u306e\u4e2d\u306e\u3001\u4e88\u7d04\u8a9e\u306e\u3088\u3046\u306a\u5b58\u5728\u306e\u3053\u3068\u3067\u3059\u3002 \u305f\u3060\u3001NVL\u3084\u3001DECODE\u7b49\u306e\u95a2\u6570\u3068\u306f\u307e\u305f\u9055\u3063\u305f\u5b58\u5728\u306b\u306a\u308a\u307e\u3059\u3002\u3088\u304f\u4f7f\u308f\u308c\u308b\u306e\u306fIN\u3084EXIST\u3001NOT NULL\u306a\u3069\u3067\u3057 [&hellip;]","protected":false},"author":1,"featured_media":4823,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[24],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/4743"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4743"}],"version-history":[{"count":16,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/4743\/revisions"}],"predecessor-version":[{"id":20591,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/4743\/revisions\/20591"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/media\/4823"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4743"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}