开发者

Postgre SQL LIKE for Integer

I've some problem in my project, we use PostgreSQL and Hibernate as ORM. I want to perform search in my table for any column type (INTEGER, STRING, TEXT). Where are some problem with Hibernate, I know what I can execute for example LIKE operator on INTEGER type lik开发者_StackOverflow中文版e this:

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

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


Try doing:

cast(size as text)

It should help.


Use CAST:

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


This may not answer your question, however if you want to find numbers that ends with 3 use the module operator

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜