Compare field with value and return bool Compare field with value and return bool postgresql postgresql

Compare field with value and return bool


You can use a CASE statement to return certain values based on a condition:

SELECT     (CASE WHEN password = 'WrittenPassword' THEN 1 ELSE 0 END) AS is_equalFROM    usersWHERE    username = 'someuser'