postgresql boolean comparison

  1. This is exactly the same as

    WHERE x
    

    It is TRUE, FALSE or NULL exactly when x is.

  2. This is the same as the first case, except when x is NULL, in which case it will be FALSE. So it is the same as

    WHERE coalesce(x, FALSE)
    
  3. This happens to be the same as the first case, since '1' is interpreted as TRUE. See the documentation:

    The datatype input function for type boolean accepts these string representations for the “true” state:

    true
    yes
    on
    1

My preferred way is the simplest:

WHERE x

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top