Skip to content

[Term Entry] SQL NULL SAFE EQUAL Operator #5205

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

Merged
merged 5 commits into from
Oct 7, 2024

Conversation

SlappyChappy
Copy link
Contributor

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
Contributor

@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
Contributor

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
Contributor

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
Contributor

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
Contributor

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
Contributor

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
Contributor

@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
Contributor 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
Contributor

@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
Contributor

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
Contributor

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
Contributor Author

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

Copy link
Contributor

@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 ,
The entry is nicely written. I think it is ready for a second round of review.

Thanks

@@ -0,0 +1,41 @@
---
Title: 'NULL SAFE EQUAL'
Description: 'Performs an equality comparison similar to the '=' operator, using the logic of an XNOR gate. Can accept NULL and ensures comparisons involving NULL do not result in NULL.'
Copy link
Contributor

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 equality comparison similar to the '=' operator, using the logic of an XNOR gate. Can accept NULL and ensures comparisons involving NULL do not result in NULL.'
Description: 'Performs an equality comparison similar to the '=' operator, using the logic of an XNOR gate. It accepts NULL values and ensures that comparisons involving NULL do not result in NULL.'

- '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
Contributor

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, it always returns 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 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
Contributor

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.

Copy link
Collaborator

@Sriparno08 Sriparno08 left a comment

Choose a reason for hiding this comment

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

Looks good, @SlappyChappy!

@Sriparno08 Sriparno08 merged commit c844a2e into Codecademy:main Oct 7, 2024
6 checks passed
Copy link

github-actions bot commented Oct 7, 2024

👋 @SlappyChappy
You have contributed to Codecademy Docs, and we would like to know more about you and your experience.
Please take a minute to fill out this four question survey to help us better understand Docs contributions and how we can improve the experience for you and our learners.
Thank you for your help!

🎉 Your contribution(s) can be seen here:

https://www.codecademy.com/resources/docs/sql/operators/null-safe-equal

Please note it may take a little while for changes to become visible.
If you're appearing as anonymous and want to be credited, see here.

@Sriparno08 Sriparno08 added status: review 2️⃣ completed hacktoberfest-accepted Indicates the PR was approved, merged, and pertains to Hacktoberfest and removed status: under review Issue or PR is currently being reviewed labels Oct 7, 2024
@Sriparno08 Sriparno08 removed the hacktoberfest-accepted Indicates the PR was approved, merged, and pertains to Hacktoberfest label Oct 7, 2024
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
4 participants