Re: [GENERAL] LIKE (SQL operator)

From: "Brett W(dot) McCoy" <bmccoy(at)lan2wan(dot)com>
To: Joao Paulo Felix <felix(at)cyclades(dot)com>
Cc: "pgsql-general(at)postgreSQL(dot)org" <pgsql-general(at)postgreSQL(dot)org>
Subject: Re: [GENERAL] LIKE (SQL operator)
Date: 1998-06-29 14:27:12
Message-ID: Pine.LNX.3.96.980629102422.868D-100000@dragosani.lan2wan.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 29 Jun 1998, Joao Paulo Felix wrote:

> I have a table called "products" which has a field named "item" with
> following data stored:
>
> "item"
> PR1000
> PR2000
> PR3000
> PRZE10
> Lze100
> Beta
> Teta
>
> Does PostgreSQL support the SQL operator "LIKE" . I have unsuccessfully
> trying the following SQL query:
>
> (SELECT * FROM products WHERE item LIKE '*PR*')
>
> I would like to select all the rows where the field "item" has the
> substring "PR" inside it.

Yes, you would use it thusly:

SELECT * FROM products WHERE item LIKE '%PR%';

The wildcards are '%' and '_', which function the same as '*' and '?',
respectively.

Brett W. McCoy
http://www.lan2wan.com/~bmccoy/
-----------------------------------------------------------------------
"The number of UNIX installations has grown to 10, with more expected."
-- The UNIX Programmer's Manual, 2nd Edition, June, 1972

In response to

Browse pgsql-general by date

  From Date Subject
Next Message bdamato 1998-06-29 19:15:30 lo_read??
Previous Message Brian 1998-06-29 12:36:45 Re: [GENERAL] vacuuming