Skip to content

Instantly share code, notes, and snippets.

@kovid-r
Last active July 10, 2020 16:31
Show Gist options
  • Save kovid-r/3ab93e4f9184748e61ccdd159d5a7f5a to your computer and use it in GitHub Desktop.
Save kovid-r/3ab93e4f9184748e61ccdd159d5a7f5a to your computer and use it in GitHub Desktop.
How integers are evaluated in SQL
/* Where evaluates the condition finally to a TRUE or FALSE */
SELECT 1 WHERE 1; -- returns one record
SELECT 1 WHERE 0; -- returns nothing
SELECT 1 WHERE 0.001; -- returns one record
/* Any non-zero number evaluates to TRUE and zero evaluates to FALSE */
SELECT 1 = TRUE; -- returns one record
SELECT 0 = FALSE; -- returns one record
SELECT 1 = FALSE; -- returns nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment