Compare field with value and return bool

I am trying to migrate a hash code from a server to PostgreSQL. In other words, I need to call a query in PGSQL, which compares the query string with the string from the field and returns the result of equal comparison as bool, but I do not know how to do this without procedures for cleaning SQL.

upd: I have a user table with a password field (currently text, in the future - bytea). I want to write sometihng as

select * from values ('WrittenPassword' = users.password) where username = 'someuser' , 

, which should return true or false as a result of equal comparison .

+4
source share
1 answer

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

 SELECT (CASE WHEN password = 'WrittenPassword' THEN 1 ELSE 0 END) AS is_equal FROM users WHERE username = 'someuser' 
+14
source

All Articles