Postgre SQL LIKE for Integer

I have some problems in my project, we use PostgreSQL and Hibernate as ORM. I want to search my table for any type of column (INTEGER, STRING, TEXT). Where are the problems with Hibernate, I know that I can execute, for example, a LIKE operator of type INTEGER, for example:

select * from Table1 where size::text like '%3'; 

But damn Hibernate takes :: TEXT as the self parameter and throws an exception. How can I avoid this error? Thanks.

+4
source share
3 answers

Try to do:

 cast(size as text) 

This should help.

+9
source

This may not answer your question, however, if you want to find numbers ending in 3 , use the module operator

 select * from Table1 where (size % 10) == 3; 
+3
source

Use CAST:

 select * from Table1 where CAST(size AS text) like '%3'; 
+1
source

Source: https://habr.com/ru/post/978051/


All Articles