I have a table like this :
> create table sample(id int, identity varchar(20)) ;
> insert into sample (id,identity) values (1,'9822');
> insert into sample (id,identity) values (2,'129822');
> insert into sample (id,identity) values (3,'ABCD9822');
> insert into sample (id,identity) values (4,'1234');
------------------------
> select * from sample ;
id | identity
----+----------
1 | 9822
2 | 129822
3 | ABCD9822
4 | 1234
(4 rows)
I have a string like 0987129822 .
how to select on database to fetch all identities ends matches by this string ?
I need this result :
id | identity
----+----------
1 | 9822
2 | 129822
Note : maybe this question duplicated , but i can not understand what keyword should i search on google .
like:select * from sample where '0987129822' like '%' || identity;identityor can theidentityhave additional leading characters? LikeXXX0987129822? Your Postgres version?