Urgent.News

650+ sources. One page. See who else covered it.

Editions

Tech

Why 'WHERE x = NULL' Never Works in SQL (And What to Use Instead)

Adapted from the SQL Essentials Companion Guide . You write a query to find every customer with no phone number on file. WHERE phone = NULL looks obviously correct — and it returns zero rows, even though you can see NULL sitting right there in the column. Nothing crashes. No error. The query just quietly lies to you about what's in the table. This isn't SQL being broken. It's SQL being consistent…

In SQL, using the condition "WHERE phone = NULL" to find customers without a phone number does not work as expected. This is because NULL does not represent "nothing" but rather "unknown". In SQL, comparing a value to NULL with the equality operator (=) always results in UNKNOWN, which is neither TRUE nor FALSE. Consequently, the WHERE clause filters out all rows, returning zero results even when there are matching records.

To correctly query for customers with no phone number, replace the equality operator with the IS NULL operator. For example, change "WHERE phone = NULL" to "WHERE phone IS NULL". This dedicated operator is specifically designed to test for the presence of NULL values. The same principle applies to other conditions using NULL. For instance, "phone != NULL" also returns no results because != is a comparison operator, and comparing anything to NULL results in UNKNOWN.

To effectively debug queries that return fewer rows than expected, first run a plain SELECT * FROM table without any WHERE clause to identify any NULL values in the relevant columns. Then, modify the query to use IS NULL (or IS NOT NULL) instead of = (or !=) for NULL checks. Remember, a column defined as NOT NULL enforces that it must always have a value, so if you suspect missing data, consider enforcing this constraint.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

The actual cost of shipping an iOS app in 2026

"How much does it cost to put an app on the App Store" gets answered inconsistently online because most answers either only count Apple's fee, or only count hardware, or quietly assume you're renting…

  • Mandatory $99/year fee for Apple Developer Program membership
  • Building and signing requires Mac, cloud Mac, or GitHub Actions
  • Public repository with GitHub Actions is most cost-effective at $99/year

GitHub Actions' free macOS minutes, explained

GitHub Actions is GitHub's built-in CI/CD system — it spins up a fresh virtual machine, runs whatever commands you tell it to, and tears the machine down when it's done.

  • GitHub Actions offers free macOS minutes for CI/CD.
  • Private repositories get 200 free macOS-runner-minutes/month on free plan.
  • Apple Developer Program fee is separate from GitHub billing.

Why your TestFlight build doesn't show up after a successful upload

You push, the build runs, the archive and export steps succeed, the upload step succeeds, the workflow finishes green. You open App Store Connect to check on it and TestFlight shows...

  • Build number must change with each upload, even if marketing version stays same
  • Use github.runnumber in GitHub Actions for dynamic build number
  • Verify dynamic build number substitution in archive step

A Context Object Should Carry Its Receipt

A stored fact can be wrong in a quiet way. The answer still reads clean. A preference from an old exchange gets reused, the message goes out with confidence, and later nobody can tell why that detail…

'We'll fix it later' is a loan. Here's the interest rate

Every time someone on your team says "we'll clean it up later," they're taking out a loan. The problem is that almost nobody checks the interest rate — until it bankrupts an entire sprint.

  • "Technical debt" refers to accrued interest in software development
  • Future productivity and complexity pay the "interest" on debt
  • Ignoring debt leads to slower development and difficult changes

More from Sunday 16 August →