I'm trying move hash cheking from server app to PostgreSQL. In other words I'm need calling a query to PGSQL, which compare string from query with string from field and return result of equal comparison as bool, but I don't know how do this without procedures on clear SQL.
upd: I have table users with field password(currently text, in the future - bytea). I want write sometihng like
select * from values ('WrittenPassword' = users.password) where username = 'someuser' ,
which must return true or false as result of equal comparison.
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_equal
FROM
users
WHERE
username = 'someuser'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With