Today I learned SQL is weird

Goal: Select all rows whose column “enabled” (boolean, nullable) is different than true

Pick your first attempt:

  • SELECT * FROM table WHERE enabled != true
  • SELECT * FROM table WHERE enabled IS NOT true
  • SELECT * FROM table WHERE enabled <> true
  • Other
  • I checked the spoiler before answering (don’t do it!)

0 voters

This is on a PostgreSQL database, don’t know if there’s any difference to MySQL/MariaDB

Spoiler (only click this after answering the poll)
SELECT * FROM table WHERE enabled != true

Nope

SELECT * FROM table WHERE enabled IS NOT true

Nope

SELECT * FROM table WHERE enabled <> true

Yes

Community Page
Last updated: