Get the latest tech news

SQL nulls are weird


Yes, you read that right. SQL does treat all NULL values differently. I learnt this a while back while working on Convoy and again on LiteQueue: a Golang a queueing library. Basically, any column wit

We’ll be comparing different values using the logical equals (“=”) operator and, even with basic programming experience, the results might not be what you expect: Let’s test a full example using the generated field, you can play around with it adding select * from sample; after each line to see the steps. Using a partial index is the best way to ensure the unique constraint is held without making your table wider, managing an extra field, it consumes less space and isn’t (AS) error-prone when deleting the same record pair over and over again!

Get the Android app

Or read this on Hacker News

Read more on:

Photo of SQL

SQL

Photo of SQL NULLs

SQL NULLs

Related news:

News photo

TiDB – cloud-native, distributed SQL database written in Go

News photo

Show HN: Execute SQL against Bluesky firehose

News photo

Advent of Code 2024 in pure SQL