Skip to content
Advertisement

Select value with prefix separated by dot in postgresql

I have a table t_table :

This is the query code : SELECT * FROM t_table

and the result is below

  code
--------
12345.a
54321.c
77777.b
77573.b

I want to select the code with suffix “.b” only. How to do it? I am new to postgreSQL

Advertisement

Answer

If you want strings that end with '.b' (that’s a suffix):

select *
from t_table
where code like '%.b'
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement