{"id":1764,"date":"2025-09-02T10:40:20","date_gmt":"2025-09-02T01:40:20","guid":{"rendered":"https:\/\/route-zero.com\/recruit\/?post_type=route&#038;p=1764"},"modified":"2025-12-02T10:40:28","modified_gmt":"2025-12-02T01:40:28","slug":"sql-null%e5%ae%8c%e5%85%a8%e6%94%bb%e7%95%a5%ef%bd%9cis-null%e3%83%bbcoalesce%e3%81%ae%e4%bd%bf%e3%81%84%e5%88%86%e3%81%91%e3%81%a8db%e5%88%a5%e3%83%90%e3%82%b0%e9%98%b2%e6%ad%a2%e8%a1%935%e9%81%b8","status":"publish","type":"route","link":"https:\/\/route-zero.com\/recruit\/route\/1764\/","title":{"rendered":"SQL NULL\u5b8c\u5168\u653b\u7565\uff5cIS NULL\u30fbCOALESCE\u306e\u4f7f\u3044\u5206\u3051\u3068DB\u5225\u30d0\u30b0\u9632\u6b62\u88535\u9078"},"content":{"rendered":"<div>\n<h2>SQL\u306eNULL\u304c\u30cf\u30de\u308b\u7406\u7531\u3068\u6b63\u3057\u3044\u4f7f\u3044\u5206\u3051<\/h2>\n<p>\n    SQL \u3092\u66f8\u3044\u3066\u3044\u3066\u3001<strong>\u300c\u3042\u308c\u3001\u30c7\u30fc\u30bf\u304c\u8fd4\u3063\u3066\u3053\u306a\u3044\uff1f\u300d<\/strong>\u305d\u3093\u306a\u7d4c\u9a13\u3001\u79c1\u305f\u3061\u306f\u3088\u304f\u3042\u308a\u307e\u3059\u3002\u3068\u304f\u306b<br \/>\n    <strong>NULL<\/strong> \u304c\u7d61\u3080\u3068\u3001\u4e00\u898b\u6b63\u3057\u304f\u898b\u3048\u308b\u30af\u30a8\u30ea\u3067\u3082\u52d5\u304d\u304c\u6b62\u307e\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n    \u305f\u3068\u3048\u3070 <strong>JOIN \u3057\u305f\u884c\u304c\u6025\u306b\u6b20\u3051\u308b<\/strong>\u3002<br \/>\n    <code>= NULL<\/code> \u3068\u66f8\u3044\u305f\u3089 <strong>\u307e\u3063\u305f\u304f\u4e00\u81f4\u3057\u306a\u3044<\/strong>\u3002<br \/>\n    \u30af\u30e9\u30a6\u30c9 DWH \u306b\u79fb\u884c\u3057\u305f\u77ac\u9593\u306b <code>COALESCE<\/code> \u306e\u6319\u52d5\u304c\u5909\u308f\u308b\u2500\u2500\u3002<br \/>\n    \u3069\u308c\u3082\u73cd\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\n    NULL \u306f\u300c\u5024\u304c\u306a\u3044\u300d\u3068\u3044\u3046\u5358\u7d14\u306a\u5b58\u5728\u306b\u898b\u3048\u3066\u3001\u305d\u306e\u88cf\u5074\u3067\u306f <strong>3\u5024\u8ad6\u7406\uff08TRUE \/ FALSE \/ UNKNOWN\uff09<\/strong> \u304c\u50cd\u304d\u3001\u79c1\u305f\u3061\u304c\u610f\u56f3\u3057\u306a\u3044\u7d50\u679c\u3092\u751f\u307f\u307e\u3059\u3002<br \/>\n    \u672c\u8a18\u4e8b\u3067\u306f\u3001<strong>IS NULL\uff0f= NULL\uff0fCOALESCE<\/strong> \u3092\u4e2d\u5fc3\u306b\u3001\u3088\u304f\u3042\u308b\u30cf\u30de\u308a\u65b9\u3092\u6574\u7406\u3057\u306a\u304c\u3089\u3001\u5b9f\u52d9\u3067\u5b89\u5168\u306b\u66f8\u3051\u308b\u30af\u30a8\u30ea\u8a2d\u8a08\u3092\u307e\u3068\u3081\u307e\u3059\u3002<br \/>\n    \u73fe\u5834\u3067\u540c\u3058\u60a9\u307f\u306b\u3076\u3064\u304b\u3063\u305f\u3068\u304d\u3001\u8ff7\u308f\u305a\u524d\u306b\u9032\u3081\u308b\u306f\u305a\u3067\u3059\u3002\n  <\/p>\n<p>\n    \uff08SQL\u306e\u57fa\u672c\u3084\u5b9f\u8df5\u7684\u306a\u4f7f\u3044\u65b9\u306b\u3064\u3044\u3066\u306f\u300e<a href=\"https:\/\/route-zero.com\/recruit\/route\/1233\/\" target=\"_blank\" rel=\"noopener\">\u521d\u5fc3\u8005\u5411\u3051SQL\u8b1b\u5ea7\uff5cSELECT\u6587\u306e\u66f8\u304d\u65b9\u3068\u5b9f\u884c\u9806\u3092\u5b8c\u5168\u89e3\u8aac<\/a\n    >\u300f\u3082\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\uff09\n  <\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aSQL<\/strong><br \/>\n      \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u64cd\u4f5c\u3059\u308b\u305f\u3081\u306e\u8a00\u8a9e\u3002\u30c7\u30fc\u30bf\u306e\u691c\u7d22\u30fb\u66f4\u65b0\u30fb\u524a\u9664\u306a\u3069\u3092\u884c\u3046\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aNULL<\/strong><br \/>\n      \u5024\u304c\u672a\u5b9a\u7fa9\u30fb\u5b58\u5728\u3057\u306a\u3044\u3053\u3068\u3092\u793a\u3059\u7279\u5225\u306a\u5024\u3002\u7a7a\u6587\u5b57\u30840\u3068\u306f\u7570\u306a\u308b\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aJOIN<\/strong><br \/>\n      \u8907\u6570\u306e\u30c6\u30fc\u30d6\u30eb\u3092\u7d50\u5408\u3057\u3001\u95a2\u9023\u3059\u308b\u30c7\u30fc\u30bf\u3092\u307e\u3068\u3081\u3066\u53d6\u5f97\u3059\u308bSQL\u306e\u6a5f\u80fd\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aCOALESCE<\/strong><br \/>\n      \u8907\u6570\u306e\u5024\u306e\u3046\u3061\u3001\u6700\u521d\u306bNULL\u3067\u306a\u3044\u5024\u3092\u8fd4\u3059SQL\u95a2\u6570\u3002NULL\u7f6e\u63db\u306b\u4f7f\u3046\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aDWH\uff08\u30c7\u30fc\u30bf\u30a6\u30a7\u30a2\u30cf\u30a6\u30b9\uff09<\/strong><br \/>\n      \u5927\u91cf\u30c7\u30fc\u30bf\u3092\u84c4\u7a4d\u30fb\u5206\u6790\u3059\u308b\u305f\u3081\u306e\u5c02\u7528\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1a3\u5024\u8ad6\u7406<\/strong><br \/>\n      TRUE\uff08\u771f\uff09\u30fbFALSE\uff08\u507d\uff09\u30fbUNKNOWN\uff08\u4e0d\u660e\uff09\u306e3\u3064\u3067\u8ad6\u7406\u5224\u5b9a\u3059\u308b\u4ed5\u7d44\u307f\u3002NULL\u304c\u7d61\u3080\u3068UNKNOWN\u306b\u306a\u308b\u3002\n    <\/p>\n<\/blockquote>\n<hr \/>\n<h2>1. SQL\u306eNULL\u304c\u30cf\u30de\u308b3\u3064\u306e\u7406\u7531<\/h2>\n<h3>1-1. NULL\u306f\u201cUnknown\u201d\u3092\u6301\u3064\u7279\u5225\u306a\u5024<\/h3>\n<p>\n    NULL \u306f\u300c\u5024\u304c\u5b58\u5728\u3057\u306a\u3044\uff0f\u4e0d\u660e\u300d\u3092\u8868\u3057\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u6bd4\u8f03\u7d50\u679c\u306f <strong>TRUE \/ FALSE \/ UNKNOWN<\/strong> \u306e\u4e09\u629e\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n    \u305f\u3068\u3048\u3070\u6b21\u306e\u6bd4\u8f03\u306f\u3059\u3079\u3066 UNKNOWN \u3067\u3059\u3002\n  <\/p>\n<pre><code>SELECT * FROM t WHERE col = NULL;\r\n<\/code><\/pre>\n<p>UNKNOWN \u306f WHERE \u53e5\u3067\u9664\u5916\u3055\u308c\u308b\u305f\u3081\u3001<strong>\u4e00\u81f4\u3057\u306a\u3044\u306e\u3067\u306f\u306a\u304f\u3001\u201c\u8a55\u4fa1\u4e0d\u80fd\u201d\u3068\u3057\u3066\u5f3e\u304b\u308c\u308b<\/strong>\u306e\u304c\u30dd\u30a4\u30f3\u30c8\u3067\u3059\u3002<\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aWHERE\u53e5<\/strong><br \/>\n      SQL\u3067\u6761\u4ef6\u3092\u6307\u5b9a\u3057\u3001\u5fc5\u8981\u306a\u30c7\u30fc\u30bf\u3060\u3051\u3092\u62bd\u51fa\u3059\u308b\u305f\u3081\u306e\u8a18\u8ff0\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aUNKNOWN<\/strong><br \/>\n      NULL\u3068\u306e\u6bd4\u8f03\u7d50\u679c\u3068\u3057\u3066\u8fd4\u308b\u300c\u4e0d\u660e\u300d\u72b6\u614b\u3002TRUE\u3067\u3082FALSE\u3067\u3082\u306a\u3044\u3002\n    <\/p>\n<\/blockquote>\n<h3>1-2. \u7a7a\u6587\u5b57\u30fb0\u30fbFALSE\u3068\u6839\u672c\u7684\u306b\u9055\u3046<\/h3>\n<p>\n    NULL \u306f\u300c\u672a\u5b9a\u7fa9\u300d\u306e\u72b6\u614b\u3067\u3059\u3002<br \/>\n    \u4ee5\u4e0b\u306e\u5024\u3068\u306f\u610f\u5473\u304c\u7570\u306a\u308a\u307e\u3059\u3002\n  <\/p>\n<ul>\n<li>\u7a7a\u6587\u5b57\uff1a<code>''<\/code>\uff08\u5024\u306f\u3042\u308b\uff09<\/li>\n<li>0\uff1a\u6570\u5024\u3068\u3057\u3066\u306e\u30bc\u30ed\uff08\u5024\u306f\u3042\u308b\uff09<\/li>\n<li>FALSE\uff1a\u8ad6\u7406\u5024\uff08\u5024\u306f\u3042\u308b\uff09<\/li>\n<\/ul>\n<p>\u3053\u306e\u9055\u3044\u3092\u6df7\u540c\u3059\u308b\u3068\u3001<strong>NULL \u306e\u307e\u307e\u6bd4\u8f03\u304c\u52d5\u304b\u306a\u3044\u554f\u984c<\/strong>\u306b\u76f4\u9762\u3057\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1a\u7a7a\u6587\u5b57<\/strong><br \/>\n      \u6587\u5b57\u5217\u578b\u3067\u5024\u304c\u7a7a\uff08&#8221;\uff09\u306e\u72b6\u614b\u3002NULL\u3068\u306f\u7570\u306a\u308a\u300c\u5024\u304c\u5b58\u5728\u3059\u308b\u300d\u6271\u3044\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aFALSE<\/strong><br \/>\n      \u8ad6\u7406\u5024\u306e\u300c\u507d\u300d\u3002\u6761\u4ef6\u5224\u5b9a\u3067\u4f7f\u308f\u308c\u308b\u3002\n    <\/p>\n<\/blockquote>\n<h3>1-3. JOIN\u30fb\u96c6\u8a08\u3067\u201c\u6c17\u3065\u304b\u306c\u629c\u3051\u201d\u304c\u8d77\u304d\u3084\u3059\u3044<\/h3>\n<p>\u5916\u90e8\u7d50\u5408\u3067\u306f\u4e00\u81f4\u3057\u306a\u3044\u884c\u306b <strong>\u5fc5\u305a NULL \u304c\u5165\u308b<\/strong>\u305f\u3081\u3001\u5f8c\u7d9a\u51e6\u7406\u3067\u30c8\u30e9\u30d6\u30eb\u304c\u8d77\u304d\u304c\u3061\u3067\u3059\u3002<\/p>\n<ul>\n<li>LEFT JOIN\uff1a\u53f3\u5074\u306e\u6b20\u640d\u304c\u3059\u3079\u3066 NULL<\/li>\n<li>GROUP BY\uff1aNULL \u3092\u542b\u3080\u96c6\u8a08\u306f\u60f3\u5b9a\u5916\u306e\u5024\u306b\u306a\u308b\u3053\u3068\u304c\u3042\u308b<\/li>\n<li>WHERE\uff1aNULL \u3092\u542b\u3080\u6bd4\u8f03\u306f UNKNOWN \u2192 \u884c\u304c\u629c\u3051\u308b<\/li>\n<\/ul>\n<p>\u3053\u3046\u3057\u305f\u300c\u4ed5\u69d8\u3068\u3057\u3066\u306e\u7f60\u300d\u304c\u3001\u79c1\u305f\u3061\u3092\u8ff7\u308f\u305b\u308b\u539f\u56e0\u3067\u3059\u3002<\/p>\n<p>\n    \uff08JOIN\u306e\u7a2e\u985e\u3084\u5b9f\u8df5\u4f8b\u306b\u3064\u3044\u3066\u306f\u300e<a href=\"https:\/\/route-zero.com\/recruit\/route\/1119\/\" target=\"_blank\" rel=\"noopener\">SQL JOIN\u306e\u57fa\u672c\u304b\u3089\u5b9f\u8df5\u307e\u3067\uff5cINNER\u30fbLEFT\u30fbRIGHT\u30fbOUTER JOIN\u306e\u9055\u3044\u3092\u308f\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac<\/a\n    >\u300f\u3082\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\uff09\n  <\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aLEFT JOIN<\/strong><br \/>\n      \u5de6\u5074\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u5168\u884c\u3068\u3001\u53f3\u5074\u306e\u4e00\u81f4\u3059\u308b\u884c\u3092\u7d50\u5408\u3002\u53f3\u5074\u306b\u4e00\u81f4\u3057\u306a\u3044\u5834\u5408\u306fNULL\u306b\u306a\u308b\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aGROUP BY<\/strong><br \/>\n      \u30c7\u30fc\u30bf\u3092\u6307\u5b9a\u3057\u305f\u5217\u3054\u3068\u306b\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u3001\u96c6\u8a08\u3059\u308bSQL\u306e\u6a5f\u80fd\u3002\n    <\/p>\n<\/blockquote>\n<hr \/>\n<h2>2. IS NULL\uff0f= NULL\uff0fCOALESCE\u306e\u6b63\u3057\u3044\u4f7f\u3044\u5206\u3051<\/h2>\n<h3>2-1. NULL\u5224\u5b9a\u306f\u5fc5\u305a <code>IS NULL<\/code><\/h3>\n<p>\u6700\u3082\u5b89\u5168\u306a\u66f8\u304d\u65b9\u306f\u3053\u308c\u3067\u3059\u3002<\/p>\n<pre><code>SELECT * FROM users WHERE deleted_at IS NULL;\r\n<\/code><\/pre>\n<p><code>= NULL<\/code> \u306f\u6bd4\u8f03\u4e0d\u53ef\u3067 UNKNOWN \u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code>-- &#x274c; \u3053\u308c\u306f\u5e38\u306b\u4e00\u81f4\u3057\u306a\u3044\r\nSELECT * FROM users WHERE name = NULL;\r\n<\/code><\/pre>\n<p>NULL \u3092\u6271\u3046\u5834\u9762\u3067\u306f\u3001<strong>IS NULL \/ IS NOT NULL \u304c\u7d76\u5bfe\u30eb\u30fc\u30eb<\/strong>\u3068\u899a\u3048\u3066\u304a\u304f\u3068\u5b89\u5168\u3067\u3059\u3002<\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aIS NULL \/ IS NOT NULL<\/strong><br \/>\n      \u5024\u304cNULL\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\u3059\u308bSQL\u306e\u69cb\u6587\u3002NULL\u6bd4\u8f03\u306f\u5fc5\u305a\u3053\u308c\u3092\u4f7f\u3046\u3002\n    <\/p>\n<\/blockquote>\n<h3>2-2. NULL\u3092\u7f6e\u63db\u3057\u305f\u3044\u3068\u304d\u306e\u95a2\u6570\u306e\u9078\u3073\u65b9<\/h3>\n<p>\u7528\u9014\u5225\u306b\u4f7f\u3044\u5206\u3051\u307e\u3059\u3002<\/p>\n<ul>\n<li><strong>COALESCE<\/strong>\uff1aANSI\u6a19\u6e96\u3002\u8907\u6570\u5f15\u6570\u306b\u5bfe\u5fdc<\/li>\n<li><strong>ISNULL<\/strong>\uff1aSQL Server<\/li>\n<li><strong>IFNULL<\/strong>\uff1aMySQL<\/li>\n<li><strong>NVL<\/strong>\uff1aOracle<\/li>\n<\/ul>\n<p>\u3082\u3063\u3068\u3082\u6c4e\u7528\u6027\u304c\u9ad8\u3044\u306e\u306f <strong>COALESCE<\/strong> \u3067\u3059\u3002<\/p>\n<pre><code>SELECT COALESCE(phone, '') AS phone_number \r\nFROM customers;\r\n<\/code><\/pre>\n<p>\u8907\u6570 DB \u3092\u307e\u305f\u3050\u74b0\u5883\u3067\u306f\u7279\u306b\u91cd\u5b9d\u3057\u307e\u3059\u3002<\/p>\n<p>\n    \uff08COALESCE\u3084\u30b5\u30d6\u30af\u30a8\u30ea\u30fbJOIN\u306e\u9055\u3044\u306b\u3064\u3044\u3066\u306f\u300e<a href=\"https:\/\/route-zero.com\/recruit\/route\/1594\/\" target=\"_blank\" rel=\"noopener\">SQL\u30b5\u30d6\u30af\u30a8\u30ea\u306f\u9045\u3044\uff1fJOIN\u30fbCTE\u3068\u306e\u9055\u3044\u3068\u9ad8\u901f\u5316\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a\n    >\u300f\u3082\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\uff09\n  <\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aANSI\u6a19\u6e96<\/strong><br \/>\n      SQL\u306e\u56fd\u969b\u6a19\u6e96\u898f\u683c\u3002\u591a\u304f\u306eDB\u3067\u5171\u901a\u3057\u3066\u4f7f\u3048\u308b\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aISNULL \/ IFNULL \/ NVL<\/strong><br \/>\n      DB\u3054\u3068\u306b\u7528\u610f\u3055\u308c\u305fNULL\u7f6e\u63db\u95a2\u6570\u3002ISNULL\u306fSQL Server\u3001IFNULL\u306fMySQL\u3001NVL\u306fOracle\u3067\u4f7f\u3046\u3002\n    <\/p>\n<\/blockquote>\n<hr \/>\n<h2>3. DB\u5225\u306b\u9055\u3046NULL\u306e\u6319\u52d5\uff08RDBMS\uff0fDWH\uff09<\/h2>\n<h3>3-1. PostgreSQL\uff1a\u6a19\u6e96\u5b9f\u88c5\u3067\u6271\u3044\u3084\u3059\u3044<\/h3>\n<p><strong>COALESCE<\/strong> \u3092\u305d\u306e\u307e\u307e\u4f7f\u3048\u3001\u6319\u52d5\u3082\u6a19\u6e96SQL\u306b\u8fd1\u3044\u3067\u3059\u3002<\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aPostgreSQL<\/strong><br \/>\n      \u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u306e\u9ad8\u6a5f\u80fd\u306aRDBMS\u3002\u6a19\u6e96SQL\u306b\u5fe0\u5b9f\u3067\u3001COALESCE\u306a\u3069\u3082\u305d\u306e\u307e\u307e\u4f7f\u3048\u308b\u3002\n    <\/p>\n<\/blockquote>\n<h3>3-2. MySQL\uff1a\u7a7a\u6587\u5b57\u3068NULL\u304c\u6df7\u3056\u308a\u3084\u3059\u3044<\/h3>\n<p>\u524d\u51e6\u7406\u306e\u6bb5\u968e\u3067\u300c\u7a7a\u6587\u5b57\u3060\u3068\u601d\u3063\u305f\u3089 NULL \u3060\u3063\u305f\u300d\u3068\u3044\u3046\u30b1\u30fc\u30b9\u304c\u591a\u3044\u305f\u3081\u3001\u6bd4\u8f03\u30fbJOIN\u306b\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aMySQL<\/strong><br \/>\n      \u4e16\u754c\u7684\u306b\u5229\u7528\u3055\u308c\u3066\u3044\u308b\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9RDBMS\u3002\u7a7a\u6587\u5b57\u3068NULL\u306e\u6271\u3044\u306b\u6ce8\u610f\u304c\u5fc5\u8981\u3002\n    <\/p>\n<\/blockquote>\n<h3>3-3. Oracle\uff1a\u7a7a\u6587\u5b57\u3092NULL\u3068\u3057\u3066\u6271\u3046<\/h3>\n<p>\n    \u6587\u5b57\u5217 <code>''<\/code> \u304c <strong>\u81ea\u52d5\u3067 NULL \u306b\u5909\u63db\u3055\u308c\u308b<\/strong>\u4ed5\u69d8\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n    WHERE \u6761\u4ef6\u3084 COALESCE \u306e\u5224\u5b9a\u7d50\u679c\u304c\u4ed6 DB \u3068\u5909\u308f\u308b\u539f\u56e0\u3067\u3059\u3002\n  <\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aOracle<\/strong><br \/>\n      \u4f01\u696d\u5411\u3051\u306b\u5e83\u304f\u4f7f\u308f\u308c\u308b\u5546\u7528RDBMS\u3002\u7a7a\u6587\u5b57\u3092\u81ea\u52d5\u7684\u306bNULL\u3068\u3057\u3066\u6271\u3046\u72ec\u81ea\u4ed5\u69d8\u304c\u3042\u308b\u3002\n    <\/p>\n<\/blockquote>\n<h3>3-4. BigQuery\uff0fSnowflake\uff1a\u578b\u63a8\u8ad6\u306e\u9055\u3044\u306b\u6ce8\u610f<\/h3>\n<p>\n    \u30af\u30e9\u30a6\u30c9 DWH \u3067\u306f\u3001\u95a2\u6570\u306e\u8a55\u4fa1\u9806\u3084\u623b\u308a\u5024\u306e\u578b\u304c\u30aa\u30f3\u30d7\u30ec RDBMS \u3068\u7570\u306a\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n    \u79fb\u884c\u6642\u306b<strong>\u300c\u540c\u3058\u30af\u30a8\u30ea\u304c\u7a81\u7136\u52d5\u304b\u306a\u3044\u300d<\/strong>\u3068\u3044\u3046\u5831\u544a\u304c\u51fa\u308b\u306e\u306f\u3053\u306e\u305f\u3081\u3067\u3059\u3002\n  <\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aBigQuery<\/strong><br \/>\n      Google\u304c\u63d0\u4f9b\u3059\u308b\u30af\u30e9\u30a6\u30c9\u578bDWH\u3002SQL\u30e9\u30a4\u30af\u306a\u30af\u30a8\u30ea\u3067\u5927\u91cf\u30c7\u30fc\u30bf\u3092\u9ad8\u901f\u51e6\u7406\u3067\u304d\u308b\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aSnowflake<\/strong><br \/>\n      \u30af\u30e9\u30a6\u30c9\u30d9\u30fc\u30b9\u306eDWH\u30b5\u30fc\u30d3\u30b9\u3002\u578b\u63a8\u8ad6\u3084\u95a2\u6570\u306e\u6319\u52d5\u304c\u4ed6DB\u3068\u7570\u306a\u308b\u5834\u5408\u304c\u3042\u308b\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1a\u578b\u63a8\u8ad6<\/strong><br \/>\n      \u30c7\u30fc\u30bf\u578b\u3092\u81ea\u52d5\u7684\u306b\u5224\u5b9a\u3059\u308b\u4ed5\u7d44\u307f\u3002DB\u3054\u3068\u306b\u6319\u52d5\u304c\u7570\u306a\u308b\u3053\u3068\u304c\u3042\u308b\u3002\n    <\/p>\n<\/blockquote>\n<hr \/>\n<h2>4. NULL\u3092\u524d\u63d0\u306b\u3057\u305f\u30af\u30a8\u30ea\u8a2d\u8a08\uff08\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\uff09<\/h2>\n<p>\u79c1\u305f\u3061\u306e\u73fe\u5834\u3067\u5171\u6709\u3057\u3066\u3044\u308b\u3001\u30b7\u30f3\u30d7\u30eb\u3067\u5f37\u529b\u306a\u30eb\u30fc\u30eb\u3067\u3059\u3002<\/p>\n<h3>4-1. WHERE\uff0fJOIN\u306f\u201cNULL\u524d\u63d0\u201d\u3067\u7d44\u307f\u7acb\u3066\u308b<\/h3>\n<pre><code>-- LEFT JOIN\u3067\u5fc5\u305aNULL\u3092\u8003\u616e\r\nSELECT u.id, COALESCE(p.name, '') \r\nFROM users u \r\nLEFT JOIN profiles p ON u.id = p.user_id;\r\n<\/code><\/pre>\n<p>\u5916\u90e8\u7d50\u5408\u306f NULL \u304c\u5165\u308a\u3084\u3059\u3044\u305f\u3081\u3001COALESCE \u3068\u30bb\u30c3\u30c8\u3067\u5b89\u5168\u6027\u304c\u9ad8\u307e\u308a\u307e\u3059\u3002<\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1a\u5916\u90e8\u7d50\u5408<\/strong><br \/>\n      LEFT JOIN\u3084RIGHT JOIN\u306a\u3069\u3001\u7d50\u5408\u6761\u4ef6\u306b\u4e00\u81f4\u3057\u306a\u3044\u5834\u5408\u3067\u3082\u7247\u65b9\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u5168\u884c\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u3002\n    <\/p>\n<\/blockquote>\n<h3>4-2. \u96c6\u8a08\u524d\u306bNULL\u3092\u9069\u5207\u306b\u51e6\u7406\u3059\u308b<\/h3>\n<p>NULL \u3092\u305d\u306e\u307e\u307e\u96c6\u8a08\u3059\u308b\u3068\u300c\u8a08\u7b97\u3057\u305f\u306e\u306b\u5024\u304c\u8fd4\u3089\u306a\u3044\u300d\u72b6\u614b\u304c\u8d77\u304d\u307e\u3059\u3002<\/p>\n<pre><code>SELECT SUM(COALESCE(amount, 0)) FROM payments;\r\n<\/code><\/pre>\n<p>\u4e8b\u524d\u306b\u7f6e\u63db\u3057\u3066\u304a\u304f\u3053\u3068\u3067\u7d50\u679c\u304c\u660e\u77ad\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aSUM\u95a2\u6570<\/strong><br \/>\n      \u6307\u5b9a\u3057\u305f\u5217\u306e\u5408\u8a08\u5024\u3092\u8a08\u7b97\u3059\u308bSQL\u95a2\u6570\u3002NULL\u304c\u3042\u308b\u3068\u5408\u8a08\u306b\u542b\u307e\u308c\u306a\u3044\u305f\u3081\u6ce8\u610f\u3002\n    <\/p>\n<\/blockquote>\n<h3>4-3. \u30c6\u30fc\u30d6\u30eb\u8a2d\u8a08\u6bb5\u968e\u3067NULL\u601d\u60f3\u3092\u63c3\u3048\u308b<\/h3>\n<ul>\n<li>NULL \u3092\u8a31\u5bb9\u3059\u308b\u7406\u7531<\/li>\n<li>NOT NULL \u306b\u3057\u305f\u3044\u5217<\/li>\n<li>\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306e\u65b9\u91dd<\/li>\n<\/ul>\n<p>\u3053\u308c\u3092\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u5316\u3057\u3066\u304a\u304f\u3068\u3001\u30c1\u30fc\u30e0\u5168\u4f53\u306e\u66f8\u304d\u65b9\u304c\u7d71\u4e00\u3055\u308c\u307e\u3059\u3002<\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aNOT NULL<\/strong><br \/>\n      \u305d\u306e\u5217\u306b\u5fc5\u305a\u5024\u304c\u5165\u308b\u3088\u3046\u5236\u7d04\u3092\u304b\u3051\u308bSQL\u306e\u6307\u5b9a\u3002NULL\u3092\u8a31\u5bb9\u3057\u306a\u3044\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1a\u30c7\u30d5\u30a9\u30eb\u30c8\u5024<\/strong><br \/>\n      \u65b0\u898f\u30ec\u30b3\u30fc\u30c9\u4f5c\u6210\u6642\u306b\u81ea\u52d5\u3067\u5165\u308b\u521d\u671f\u5024\u3002NULL\u56de\u907f\u3084\u904b\u7528\u7d71\u4e00\u306b\u5f79\u7acb\u3064\u3002\n    <\/p>\n<\/blockquote>\n<hr \/>\n<h2>5. \u79fb\u884c\u30fb\u7d71\u5408\u3067NULL\u304c\u58ca\u308c\u3084\u3059\u30443\u30dd\u30a4\u30f3\u30c8<\/h2>\n<h3>5-1. \u578b\u306e\u9055\u3044\u304b\u3089NULL\u304c\u6df7\u5165\u3059\u308b<\/h3>\n<p>DB \u9593\u79fb\u884c\u3067\u6587\u5b57\u5217\u578b\u304c\u5909\u308f\u308b\u3068\u3001\u7a7a\u6587\u5b57\u2192NULL \u3078\u5909\u63db\u3055\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1a\u578b\u5909\u63db<\/strong><br \/>\n      \u30c7\u30fc\u30bf\u578b\u3092\u5225\u306e\u578b\u306b\u5909\u63db\u3059\u308b\u3053\u3068\u3002\u79fb\u884c\u6642\u306bNULL\u304c\u6df7\u5165\u3057\u3084\u3059\u3044\u3002\n    <\/p>\n<\/blockquote>\n<h3>5-2. ETL\uff0fELT\u5de5\u7a0b\u3067\u610f\u56f3\u3057\u306a\u3044\u7f6e\u63db\u304c\u8d77\u304d\u308b<\/h3>\n<p>NULL \u3092\u7a7a\u6587\u5b57\u30840\u306b\u8aa4\u5909\u63db\u3059\u308b\u3068\u3001\u5f8c\u7d9a\u51e6\u7406\u3067\u610f\u5473\u304c\u5909\u308f\u308a\u307e\u3059\u3002<\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aETL\uff0fELT<\/strong><br \/>\n      \u30c7\u30fc\u30bf\u62bd\u51fa\u30fb\u5909\u63db\u30fb\u683c\u7d0d\uff08ETL\uff09\u3001\u307e\u305f\u306f\u62bd\u51fa\u30fb\u683c\u7d0d\u5f8c\u306b\u5909\u63db\uff08ELT\uff09\u3059\u308b\u5de5\u7a0b\u3002NULL\u306e\u6271\u3044\u306b\u6ce8\u610f\u3002\n    <\/p>\n<\/blockquote>\n<h3>5-3. \u65e2\u5b58\u30af\u30a8\u30ea\u306e\u66f8\u304d\u65b9\u304c\u901a\u7528\u3057\u306a\u3044<\/h3>\n<p><code>COALESCE<\/code> \u3084 <code>ISNULL<\/code> \u306e\u6271\u3044\u304c\u9055\u3046\u305f\u3081\u3001\u79fb\u884c\u5f8c\u306b\u30ed\u30b8\u30c3\u30af\u30a8\u30e9\u30fc\u304c\u751f\u307e\u308c\u3084\u3059\u3044\u90e8\u5206\u3067\u3059\u3002<\/p>\n<p>\n    \uff08SQL\u30a8\u30e9\u30fc\u306e\u539f\u56e0\u3084\u5bfe\u7b56\u306b\u3064\u3044\u3066\u306f\u300e<a href=\"https:\/\/route-zero.com\/recruit\/route\/1283\" target=\"_blank\" rel=\"noopener\">SQL Syntax Error\u306e\u539f\u56e0\u3068\u5bfe\u51e6\u30c1\u30a7\u30c3\u30af\u30ea\u30b9\u30c8\uff5c\u4eca\u3059\u3050\u8a66\u305b\u308b\u30a8\u30e9\u30fc\u89e3\u6c7a\u6cd5<\/a\n    >\u300f\u3082\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\uff09\n  <\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1a\u30ed\u30b8\u30c3\u30af\u30a8\u30e9\u30fc<\/strong><br \/>\n      \u30d7\u30ed\u30b0\u30e9\u30e0\u3084\u30af\u30a8\u30ea\u306e\u8a2d\u8a08\u30df\u30b9\u306b\u3088\u308b\u610f\u56f3\u3057\u306a\u3044\u52d5\u4f5c\u3002NULL\u306e\u6271\u3044\u9055\u3044\u3067\u767a\u751f\u3057\u3084\u3059\u3044\u3002\n    <\/p>\n<\/blockquote>\n<hr \/>\n<h2>\u307e\u3068\u3081\uff1aNULL\u306f\u6575\u3067\u306f\u306a\u304f\u201c\u4ed5\u69d8\u201d\u3002\u7406\u89e3\u3059\u308c\u3070\u5f37\u529b\u306a\u6b66\u5668\u306b\u306a\u308b<\/h2>\n<p>NULL \u306f\u8907\u96d1\u3067\u306f\u3042\u308a\u307e\u3059\u304c\u3001\u4ed5\u69d8\u3092\u7406\u89e3\u3059\u308c\u3070\u78ba\u5b9f\u306b\u6271\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li><strong>NULL \u306f Unknown \u3092\u542b\u3080\u4e09\u5024\u8ad6\u7406<\/strong><\/li>\n<li><strong>\u5224\u5b9a\u306f IS NULL \u304c\u7d76\u5bfe<\/strong><\/li>\n<li><strong>\u7f6e\u63db\u306f COALESCE \u304c\u6700\u3082\u6c4e\u7528<\/strong><\/li>\n<li><strong>DB \u3054\u3068\u306e\u9055\u3044\u3092\u628a\u63e1\u3057\u3066\u304a\u304f<\/strong><\/li>\n<li><strong>NULL \u524d\u63d0\u3067\u30af\u30a8\u30ea\u3092\u8a2d\u8a08\u3059\u308b<\/strong><\/li>\n<\/ul>\n<p>\n    \u3069\u308c\u3082\u7279\u5225\u306a\u30c6\u30af\u30cb\u30c3\u30af\u3067\u306f\u306a\u304f\u3001\u73fe\u5834\u3067\u5f79\u7acb\u3064\u57fa\u672c\u3067\u3059\u3002<br \/>\n    \u305c\u3072\u3001\u304a\u624b\u5143\u306e\u30af\u30a8\u30ea\u3067\u3082\u52d5\u4f5c\u3092\u8a66\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002\n  <\/p>\n<\/div>\n","protected":false},"featured_media":1769,"template":"","_links":{"self":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/route\/1764"}],"collection":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/route"}],"about":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/types\/route"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/media\/1769"}],"wp:attachment":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/media?parent=1764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}