Underscore "_" in LIKE pattern

From: Stefan Schwarzer <stefan(dot)schwarzer(at)grid(dot)unep(dot)ch>
To: pgsql-general(at)postgresql(dot)org
Subject: Underscore "_" in LIKE pattern
Date: 2008-05-14 10:09:09
Message-ID: 71EB91DE-CBA6-46A4-995B-C266A2ADB421@grid.unep.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi there,

I would like to get a list of all tables in my schema which begin with
"in_". But as the "underscore (_) in pattern stands for (matches) any
single character", my query:

SELECT * FROM pg_tables WHERE schemaname='public' AND tablename LIKE
'in_%' ORDER BY tablename ASC

doesn't exactly do what I want.

It retrieves me tables like this one (which is what I want):

in_water_use_ind

but also tables like this one (which is not what I want):

ind_gdp

I am sure this is just a minor thing. But I have no idea how to solve
it.

Thanks for any hints!

Stef

Browse pgsql-general by date

  From Date Subject
Next Message ludwig 2008-05-14 10:42:25 Re: Underscore "_" in LIKE pattern
Previous Message J. Manuel Velasco - UBILIBET 2008-05-14 08:35:01 Re: how can i get initdb