1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 15:18:01 +00:00

Add Is It Null Or Not Null as a postgres til.

This commit is contained in:
jbranchaud
2016-01-07 17:22:11 -06:00
parent b3384eef09
commit 37edf4dcb0
2 changed files with 26 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
# Is It Null Or Not Null?
In PostgreSQL, the standard way to check if something is `NULL` is like so:
```sql
select * as wild_pokemons from pokemons where trainer_id is null;
```
To check if something is not null, you just add `not`:
```sql
select * as captured_pokemons from pokemons where trainer_id is not null;
```
PostgreSQL also comes with `ISNULL` and `NOTNULL` which are non-standard
ways of doing the same as above:
```sql
select * as wild_pokemons from pokemons where trainer_id isnull;
```
```sql
select * as captured_pokemons from pokemons where trainer_id notnull;
```