Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Term Entry] SQL NULL SAFE EQUAL Operator #5205

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

SlappyChappy
Copy link

Description

Adding SQL NULL SAFE EQUAL operator to SQL concepts under docs/content/sql/concepts/operators/terms/null-safe-equal/null-safe-equal.md.

I am making this contribution as part of my Git & Github course on Codecademy.

Issue Solved

Closes #5166

Type of Change

  • Adding a new entry

Checklist

  • All writings are my own.
  • My entry follows the Codecademy Docs style guide.
  • My changes generate no new warnings.
  • I have performed a self-review of my own writing and code.
  • I have checked my entry and corrected any misspellings.
  • I have made corresponding changes to the documentation if needed.
  • I have confirmed my changes are not being pushed from my forked main branch.
  • I have confirmed that I'm pushing from a new branch named after the changes I'm making.
  • I have linked any issues that are relevant to this PR in the Issues Solved section.

@CLAassistant
Copy link

CLAassistant commented Sep 9, 2024

CLA assistant check
All committers have signed the CLA.

@SaviDahegaonkar SaviDahegaonkar self-assigned this Sep 9, 2024
@SaviDahegaonkar SaviDahegaonkar added sql SQL entries new entry New entry or entries status: under review Issue or PR is currently being reviewed labels Sep 9, 2024
Copy link
Collaborator

@SaviDahegaonkar SaviDahegaonkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @SlappyChappy ,
I had a look at your PR and suggested a few changes to you that should be made asap to get it approved as a first review.

Thanks,
Savi

@@ -0,0 +1,40 @@
---
Title: 'NULL SAFE EQUAL'
Description: 'Performs an inequality comparison similar to the '=' operator, using the logic of an XNOR gate. Can accept NULL as a value and will not output NULL.'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Description: 'Performs an inequality comparison similar to the '=' operator, using the logic of an XNOR gate. Can accept NULL as a value and will not output NULL.'
Description: 'Performs an equality comparison similar to the '=' operator, using the logic of an XNOR gate. Can accept NULL as a value and ensures comparisons involving NULL do not result in NULL.

Here I have corrected inequality comparison to equality comparison because that is the correct logic for null safe equal operator in SQL.

Comment on lines 6 to 10
Tags:
- 'Operators'
- 'Database'
- 'Queries'
- 'Tables'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Tags:
- 'Operators'
- 'Database'
- 'Queries'
- 'Tables'
Tags:
- 'Operators'
- 'Database'
- 'Queries'
- 'Tables'

Include only those tags that are already present in the tags.md list and you can add one if you want to include it in your PR. Here operators is not part of the tags list so you can add it if you want it to be used.

- 'paths/analyze-data-with-sql'
---

The **'NULL SAFE EQUAL'** operator performs an equality comparison like the '=' operator. However it can also accept NULL values and never returns NULL, instead always returning TRUE or FALSE. It uses the logic of an XNOR gate to determine the value returned.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The **'NULL SAFE EQUAL'** operator performs an equality comparison like the '=' operator. However it can also accept NULL values and never returns NULL, instead always returning TRUE or FALSE. It uses the logic of an XNOR gate to determine the value returned.
The **`NULL SAFE EQUAL`** operator performs an equality comparison like the '=' operator. However, it can also accept NULL values and never returns NULL, instead always returning TRUE or FALSE. It uses the logic of an XNOR gate to determine the value returned.


The **'NULL SAFE EQUAL'** operator performs an equality comparison like the '=' operator. However it can also accept NULL values and never returns NULL, instead always returning TRUE or FALSE. It uses the logic of an XNOR gate to determine the value returned.

The 'NULL SAFE EQUAL' function is useful for when an XNOR gate that can accept NULL values and always returns True or False is needed.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The 'NULL SAFE EQUAL' function is useful for when an XNOR gate that can accept NULL values and always returns True or False is needed.
The `NULL SAFE EQUAL` operator is useful when an XNOR-like logic is required for comparisons that can accept NULL values and always return True or False.

The NULL SAFE EQUAL is an operator so it must be enclosed in ..... backticks, also removed the function word as it is not a function.
Also, NULL SAFE EQUAL operator is useful when XNOR-like logic is required not literally an XNOR gate.


> **Note:** The syntax can vary across different SQL flavors. In PostgreSQL, the operator is written as 'a IS NOT DISTINCT FROM b'. In MariaDB/MySQL, it is written as 'a <=> b'. Finally, in SQLite, it is written as 'a IS b'.

## MySQL Syntax
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## MySQL Syntax
## Syntax

Removed MYSQL as it is not necessary here, only the word syntax is sufficient.

Copy link
Collaborator

@SaviDahegaonkar SaviDahegaonkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @SlappyChappy ,
I had a look at your PR and suggested some changes to you. Please make them asap to get it approved

Thanks,
Savi

@SlappyChappy
Copy link
Author

@SaviDahegaonkar I have made a second commit following the suggestions you have made. Please let me know if you have any other comments. One thing to note was that I am not fully sure of what you mean regarding the 'Operators' tag, as when I looked in docs/documentation/tags.md, I was able to find it in there, so please let me know if I need to modify the tags section again.

Copy link
Collaborator

@SaviDahegaonkar SaviDahegaonkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @SlappyChappy ,
I had a look at your PR. I have suggested a few more changes to you please make them asap.

Thanks,
Savi


The **`NULL SAFE EQUAL`** operator performs an equality comparison like the '=' operator. However, it can also accept NULL values and never returns NULL, instead always returning TRUE or FALSE. It uses the logic of an XNOR gate to determine the value returned.

The 'NULL SAFE EQUAL' operator is useful for when XNOR-like logic is required for comparisons that can accept NULL values and always return True or False is needed.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The 'NULL SAFE EQUAL' operator is useful for when XNOR-like logic is required for comparisons that can accept NULL values and always return True or False is needed.
The `NULL SAFE EQUAL` operator is useful when XNOR-like logic is required for comparisons that can accept NULL values and always return True or False.

NULL SAFE EQUAL is an operator therefore it must be enclosed in (.....) backticks.

Comment on lines 24 to 28
```pseudo
SELECT column1
FROM table
WHERE column1 <=> condition
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```pseudo
SELECT column1
FROM table
WHERE column1 <=> condition
```
```pseudo
SELECT column1
FROM table
WHERE column1 <=> value;
The NULL SAFE EQUAL operator <=> does the comparison between two values , not with the word "condition".

@SlappyChappy
Copy link
Author

@SaviDahegaonkar I have incorporated your suggestions. Please let me know if there is anything else to amend. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Concept Entry] NULL SAFE EQUAL operator in sql
3 participants