main
sudo pacman -Syu 2025-01-12 00:07:13 +07:00
parent 87cec26150
commit 0c7cefa467
2 changed files with 27 additions and 4 deletions

View File

@ -283,7 +283,11 @@
<span class="pl-k">FROM</span> table
<span class="pl-k">WHERE</span> (field_something IS <span class="pl-k">NULL</span> <span class="pl-k">OR</span> field_something <span class="pl-k">!=</span> <span class="pl-c1">1</span>)</pre>
</div>
<p>Need clarify why this happen? Idk :(</p>
<p>
Because <code>NULL</code> is not equal to anything, even
<code>NULL != NULL</code>, we only can check with <code>IS NULL</code> or
<code>IS NOT NULL</code>.
</p>
<div class="markdown-heading">
<h2 class="heading-element"><code>VARCHAR</code> or <code>TEXT</code></h2>
<a
@ -516,10 +520,26 @@
<a
href="https://www.depesz.com/2024/12/01/sql-best-practices-dont-compare-count-with-0/"
rel="nofollow"
>SQL best practices dont compare count(*) with 0</a
>SQL best practices dont compare count with 0</a
>
</p>
</li>
<li>
<p>
<a
href="https://jirevwe.github.io/sql-nulls-are-weird.html"
rel="nofollow"
>SQL NULLs are Weird!</a
>
</p>
<ul>
<li>
<a href="https://www.sqlite.org/nulls.html" rel="nofollow"
>NULL Handling in SQLite Versus Other Database Engines</a
>
</li>
</ul>
</li>
</ul>
<div>

View File

@ -131,7 +131,8 @@ FROM table
WHERE (field_something IS NULL OR field_something != 1)
```
Need clarify why this happen? Idk :(
Because `NULL` is not equal to anything, even `NULL != NULL`, we only can check
with `IS NULL` or `IS NOT NULL`.
## `VARCHAR` or `TEXT`
@ -192,4 +193,6 @@ FROM information_schema.statistics;
- [Difference between text and varchar (character varying)](https://stackoverflow.com/a/4849030)
- [How to get the number of total results when there is LIMIT in query?](https://stackoverflow.com/q/33889922)
- [Run a query with a LIMIT/OFFSET and also get the total number of rows](https://stackoverflow.com/q/28888375)
- [SQL best practices dont compare count(*) with 0](https://www.depesz.com/2024/12/01/sql-best-practices-dont-compare-count-with-0/)
- [SQL best practices dont compare count with 0](https://www.depesz.com/2024/12/01/sql-best-practices-dont-compare-count-with-0/)
- [SQL NULLs are Weird!](https://jirevwe.github.io/sql-nulls-are-weird.html)
- [NULL Handling in SQLite Versus Other Database Engines](https://www.sqlite.org/nulls.html)