Postgres SELECT where the WHERE is UUID or string

Found it! Casting the UUID column to ::text stops the error. Not sure about the performance hit but on about 5000 rows I get more than adequate performance.

SELECT * FROM user
WHERE id::text="jsdfhiureeirh" OR uid = 'jsdfhiureeirh';

SELECT * FROM user
WHERE id::text="33bb9554-c616-42e6-a9c6-88d3bba4221c" 
  OR uid = '33bb9554-c616-42e6-a9c6-88d3bba4221c';

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)