{"id":8521,"date":"2020-11-17T07:02:00","date_gmt":"2020-11-17T07:02:00","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=8521"},"modified":"2025-08-26T04:42:12","modified_gmt":"2025-08-26T04:42:12","slug":"how-to-compare-null-values-in-mysql","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/","title":{"rendered":"How to Compare Null Values in MySQL"},"content":{"rendered":"\n<p>Sometimes you may need to compare a column with null value or compare two columns where one of them has null values, or even perform null check for columns. Null values mean missing or unknown values and are often present in real world data. They behave differently compared to similar values such as empty strings and dates. They can often trip beginner database developers who assume them to work the same way as strings and dates, while comparing values. In this article we will look at how to compare null values in MySQL. You can use it for Null comparison in MySQL.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/#Understanding_NULL_values_in_MySQL\" >Understanding NULL values in MySQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/#How_to_Compare_Null_Values_in_MySQL\" >How to Compare Null Values in MySQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/#Using_Is_Null\" >Using Is Null<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/#Using_Is_Not_Null\" >Using Is Not Null<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/#With_UPDATE_Statement\" >With UPDATE Statement<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/#With_INSERT_Statement\" >With INSERT Statement<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/#With_DELETE_Statement\" >With DELETE Statement<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Understanding_NULL_values_in_MySQL\"><\/span>Understanding NULL values in MySQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In MySQL, and in most other databases, null values react very differently from strings and other data types while performing comparisons. For example, if you check the condition null=null, it will not return True or False but return Null instead. If you compare null with any non-null value, such as null=&#8217;abc&#8217; the result will again be null and not True\/False. This makes it difficult to filter rows based on columns which can have null values. For this purpose, you need to use <em>is null<\/em> and <em>is not null<\/em> operators respectively. Sometimes, you may need to <a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-alter-column-from-null-to-not-null\/\">alter column from NULL to NOT NULL<\/a> before doing a comparison.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Compare_Null_Values_in_MySQL\"><\/span>How to Compare Null Values in MySQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Let us  say you have the following table <em>sales(id, order_date, cost_price, selling_price)<\/em><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; create table sales(<br>                id int, <br>                order_date date, <br>                cost_price int, <br>                selling_price int);<br><br>mysql&gt; describe sales;<br>+---------------+---------+------+-----+---------+-------+<br>| Field         | Type    | Null | Key | Default | Extra |<br>+---------------+---------+------+-----+---------+-------+<br>| id            | int(11) | YES  |     | NULL    |       |<br>| order_date    | date    | YES  |     | NULL    |       |<br>| cost_price    | int(11) | YES  |     | NULL    |       |<br>| selling_price | int(11) | YES  |     | NULL    |       |<br>+---------------+---------+------+-----+---------+-------+<br><br>mysql&gt; insert into sales(id,order_date,cost_price,selling_price)<br>       values(1,'2020-11-01',150,250),<br>             (2,'2020-11-02',200,300);<br><br>mysql&gt; insert into sales(id,order_date, cost_price) <br>       values(3, '2020-11-03',100);<br><br>mysql&gt; insert into sales(id,order_date, selling_price) <br>       values(4, '2020-11-03',100);<br><br>mysql&gt; select * from sales;<br>+------+------------+------------+---------------+<br>| id   | order_date | cost_price | selling_price |<br>+------+------------+------------+---------------+<br>|    1 | 2020-11-01 |        150 |           250 |<br>|    2 | 2020-11-02 |        200 |           300 |<br>|    3 | 2020-11-03 |        100 |          NULL |<br>|    4 | 2020-11-03 |       NULL |           100 |<br>+------+------------+------------+---------------+<\/pre>\n\n\n\n<p>Let us say you want to select rows where cost price is null. Typically, you would use an expression such as <em>cost_price=null<\/em> but it does not work with NULL values. In case of null comparison, you need to use <strong>IS<\/strong> operator, that is, <em>cost_price IS null<\/em><\/p>\n\n\n\n<p>So the following SQL query <strong>will not work<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select * from sales where cost_price<strong>=null<\/strong>;\nEmpty set (0.00 sec)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Using_Is_Null\"><\/span>Using Is Null<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>To filter rows that contain column value to be null, you need to use <em>is null<\/em> operator. Here is its syntax.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">column_name is null<\/pre>\n\n\n\n<p>The following SQL query <strong>will work<\/strong>. Here is the SQL query to select rows where cost_price is null.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select * from sales where cost_price <strong>is null<\/strong>;<br>+------+------------+------------+---------------+<br>| id   | order_date | cost_price | selling_price |<br>+------+------------+------------+---------------+<br>|    4 | 2020-11-03 |       NULL |           100 |<br>+------+------------+------------+---------------+<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Using_Is_Not_Null\"><\/span>Using Is Not Null<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>On the other hand, if you want to filter rows where column value is not null, then use <em>is not null<\/em> operator.<\/p>\n\n\n\n<p>Similarly, here is the SQL query to select rows where cost_price is not NULL. In this case, we use <strong>IS NOT<\/strong> operator.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select * from sales where cost_price <strong>is not null<\/strong>;<br>+------+------------+------------+---------------+<br>| id   | order_date | cost_price | selling_price |<br>+------+------------+------------+---------------+<br>|    1 | 2020-11-01 |        150 |           250 |<br>|    2 | 2020-11-02 |        200 |           300 |<br>|    3 | 2020-11-03 |        100 |          NULL |<br>+------+------------+------------+---------------+<\/pre>\n\n\n\n<p>You can use IS NULL and IS NOT NULL with UPDATE, INSERT and DELETE statement. Here are some examples to illustrate it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"With_UPDATE_Statement\"><\/span>With UPDATE Statement<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; update sales\n       set selling_price=350\n       where cost_price is null;\n\nmysql&gt; select * from sales;\n+------+------------+------------+---------------+\n| id   | order_date | cost_price | selling_price |\n+------+------------+------------+---------------+\n|    1 | 2020-11-01 |        150 |           250 |\n|    2 | 2020-11-02 |        200 |           300 |\n|    3 | 2020-11-03 |        100 |          NULL |\n|    4 | 2020-11-03 |       NULL |           <strong>350<\/strong> |\n+------+------------+------------+---------------+<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"With_INSERT_Statement\"><\/span>With INSERT Statement<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here&#8217;s an example that uses MySQL NULL Comparison in INSERT statement.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; insert into new_sales(id,order_date, cost_price, selling_price)\n      select * from sales\n      where cost_price <strong>is null<\/strong>;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"With_DELETE_Statement\"><\/span>With DELETE Statement<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here&#8217;s an example to use Null comparison in Delete Statement.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; delete from sales<br>       where cost_price is null;<br><br>mysql&gt; select * from sales;<br>+------+------------+------------+---------------+<br>| id   | order_date | cost_price | selling_price |<br>+------+------------+------------+---------------+<br>|    1 | 2020-11-01 |        150 |           250 |<br>|    2 | 2020-11-02 |        200 |           300 |<br>|    3 | 2020-11-03 |        100 |          NULL |<br>+------+------------+------------+---------------+<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Most real-world databases have columns with null values. They behave quite differently compared to other columns when it comes to comparison. Therefore, if you use the traditional comparison operators, you may not get desired result. You need to use <em>is null<\/em> and <em>is not null<\/em> operators for this purpose. Hopefully, this article will help you compare NULL values in MySQL. <\/p>\n\n\n\n<p><a href=\"https:\/\/ubiq.co\/\">Ubiq<\/a> makes it easy to visualize data, and monitor them in real-time dashboards. <a href=\"https:\/\/ubiq.co\/accounts\/register\">Try Ubiq<\/a> for free.<\/p>\n\n\n\n<p>Also read:<br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/\">How to Add Auto Increment Column in MySQL Table<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/top-5-free-database-design-tools\/\">Top Free Database Design Tools<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-replicate-mysql-database-to-another-server\/\">How to Replicate MySQL Server<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you may need to compare null values in MySQL. Here is how to compare null values in MySQL for Null Comparison.<\/p>\n","protected":false},"author":1,"featured_media":8524,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[324],"tags":[481],"class_list":["post-8521","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql","tag-null-comparison"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Compare Null Values in MySQL - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Sometimes you may need to compare null values in MySQL. Here is how to compare null values in MySQL for Null Comparison.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Compare Null Values in MySQL - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Sometimes you may need to compare null values in MySQL. Here is how to compare null values in MySQL for Null Comparison.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-17T07:02:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-26T04:42:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/mysql-null-comparison1.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"730\" \/>\n\t<meta property=\"og:image:height\" content=\"410\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-compare-null-values-in-mysql\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-compare-null-values-in-mysql\\\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How to Compare Null Values in MySQL\",\"datePublished\":\"2020-11-17T07:02:00+00:00\",\"dateModified\":\"2025-08-26T04:42:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-compare-null-values-in-mysql\\\/\"},\"wordCount\":546,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-compare-null-values-in-mysql\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/mysql-null-comparison1.webp?fit=730%2C410&ssl=1\",\"keywords\":[\"null comparison\"],\"articleSection\":[\"MySQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-compare-null-values-in-mysql\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-compare-null-values-in-mysql\\\/\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-compare-null-values-in-mysql\\\/\",\"name\":\"How to Compare Null Values in MySQL - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-compare-null-values-in-mysql\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-compare-null-values-in-mysql\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/mysql-null-comparison1.webp?fit=730%2C410&ssl=1\",\"datePublished\":\"2020-11-17T07:02:00+00:00\",\"dateModified\":\"2025-08-26T04:42:12+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Sometimes you may need to compare null values in MySQL. Here is how to compare null values in MySQL for Null Comparison.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-compare-null-values-in-mysql\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-compare-null-values-in-mysql\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-compare-null-values-in-mysql\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/mysql-null-comparison1.webp?fit=730%2C410&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/mysql-null-comparison1.webp?fit=730%2C410&ssl=1\",\"width\":730,\"height\":410,\"caption\":\"not null comparison in mysql\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-compare-null-values-in-mysql\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Compare Null Values in MySQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/sreeram-sreenivasan\\\/\"],\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/author\\\/wordpress\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Compare Null Values in MySQL - Ubiq BI","description":"Sometimes you may need to compare null values in MySQL. Here is how to compare null values in MySQL for Null Comparison.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/","og_locale":"en_US","og_type":"article","og_title":"How to Compare Null Values in MySQL - Ubiq BI","og_description":"Sometimes you may need to compare null values in MySQL. Here is how to compare null values in MySQL for Null Comparison.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2020-11-17T07:02:00+00:00","article_modified_time":"2025-08-26T04:42:12+00:00","og_image":[{"width":730,"height":410,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/mysql-null-comparison1.webp","type":"image\/webp"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How to Compare Null Values in MySQL","datePublished":"2020-11-17T07:02:00+00:00","dateModified":"2025-08-26T04:42:12+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/"},"wordCount":546,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/mysql-null-comparison1.webp?fit=730%2C410&ssl=1","keywords":["null comparison"],"articleSection":["MySQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/","name":"How to Compare Null Values in MySQL - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/mysql-null-comparison1.webp?fit=730%2C410&ssl=1","datePublished":"2020-11-17T07:02:00+00:00","dateModified":"2025-08-26T04:42:12+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Sometimes you may need to compare null values in MySQL. Here is how to compare null values in MySQL for Null Comparison.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/mysql-null-comparison1.webp?fit=730%2C410&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/mysql-null-comparison1.webp?fit=730%2C410&ssl=1","width":730,"height":410,"caption":"not null comparison in mysql"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-compare-null-values-in-mysql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How to Compare Null Values in MySQL"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/mysql-null-comparison1.webp?fit=730%2C410&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-2dr","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8521","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=8521"}],"version-history":[{"count":5,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8521\/revisions"}],"predecessor-version":[{"id":9293,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8521\/revisions\/9293"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/8524"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=8521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=8521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=8521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}