---
title: "Difference between two expression results with a NULL value"  
description: "Difference between two expression results with a NULL value"  
author: "Steilla Mitchel"  
published: 2023-07-30  
updated: 2023-07-31  
canonical: https://www.mindstick.com/forum/159364/difference-between-two-expression-results-with-a-null-value  
category: "mssql server"  
tags: ["sql server", "sql"]  
reading_time: 2 minutes  

---

# Difference between two expression results with a NULL value

The [difference between two](https://www.mindstick.com/forum/160701/how-to-calculate-the-difference-between-two-dates-in-c-sharp) [expression](https://www.mindstick.com/articles/1861/sqlite-expressions) [results](https://yourviews.mindstick.com/story/4497/usage-of-baking-soda-magical-results) with a [NULL value](https://www.mindstick.com/forum/23045/document-body-appendchild-has-a-null-value)

## Replies

### Reply by Aryan Kumar

Sure, here is the [difference](https://www.mindstick.com/articles/157114/good-news-or-bad-news-and-the-difference-is) between two expression results with a [null](https://www.mindstick.com/forum/33922/how-to-use-null-coalescing-operator-in-c-sharp) [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) in SQL:

- `==` will return `NULL` if either of the expressions is null. This is because the `==` operator only returns `TRUE` if both of the expressions are equal. If one of the expressions is null, then the `==` operator will return `NULL`.
- `IS NULL` will return `TRUE` if the expression is null and `FALSE` if the expression is not null. This is because the `IS NULL` operator specifically checks if the expression is null.
- `!==` will return `TRUE` if either of the expressions is not null and `FALSE` if both of the expressions are null. This is because the `!==` operator only returns `TRUE` if the expressions are not equal. If one of the expressions is null, then the `!==` operator will return `FALSE`.

Here is an example of how the three operators would work:

SQL

```plaintext
SELECT
  expression1,
  expression2,
  expression1 = expression2,
  expression1 IS NULL,
  expression2 IS NULL;
```

If `expression1` and `expression2` are both null, then the following results will be returned:

```plaintext
expression1 | expression2 | expression1 = expression2 | expression1 IS NULL | expression2 IS NULL
---------- | -------- | ------------------- | --------------- | ---------------
NULL       | NULL       | NULL                | TRUE             | TRUE
```

If `expression1` is null and `expression2` is not null, then the following results will be returned:

```plaintext
expression1 | expression2 | expression1 = expression2 | expression1 IS NULL | expression2 IS NULL
---------- | -------- | ------------------- | --------------- | ---------------
NULL       | 'hello'   | NULL                | TRUE             | FALSE
```

If `expression1` is not null and `expression2` is null, then the following results will be returned:

```plaintext
expression1 | expression2 | expression1 = expression2 | expression1 IS NULL | expression2 IS NULL
---------- | -------- | ------------------- | --------------- | ---------------
'hello'   | NULL       | NULL                | FALSE            | TRUE
```


---

Original Source: https://www.mindstick.com/forum/159364/difference-between-two-expression-results-with-a-null-value

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
