Re: simple query question

From: Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com>
To: Gregory Wood <gregw(at)com-stock(dot)com>, Dan Maher <dan(dot)maher(at)home(dot)com>
Cc: PostgreSQL-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: simple query question
Date: 2001-12-27 16:46:18
Message-ID: 20011227164618.44256.qmail@web20810.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

The "best" solution depends on the structure of your
data, and how many assumptions you can validly make
about it.
A generalized solution would be:
...WHERE position (test_string in field_name) > 0
which will tell you whether your string is contained
within the field contents.
If you want a case-insensitive match, use lower() or
upper() on the two strings being compared.
HTH.

--- Gregory Wood <gregw(at)com-stock(dot)com> wrote:
> > I want to find a row in a table that has a column
> that matches a string
> like
> >
> > "jack nicholson - one flew over the cuckoo's nest"
> >
> > but the columns I have are:
> >
> > actor movie
> > ------ --------
> > jack nicholson One flew over the cuckoo's nest
>
> You should be able to concatenate both fields
> together (with the spaces and
> dash) when doing your search:
>
> UPDATE blah WHERE actor||' - '||movie = "jack
> nicholson - one flew over the
> cuckoo's nest";
>
> Remember, it's just a comparison operator... it just
> compares what's on the
> left side to the right, not just a single column
> with another value.
>
> > <sql idiot mode>
> > Also, if there is a DB-independent way to do this
> without a specific
> > PostgreSQL operator, that would be ideal.
> > </sql idiot mode>
>
> I believe || is SQL standard for concatenation, so
> you should be fine using
> that.
>
> Greg
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the
> unregister command
> (send "unregister YourEmailAddressHere" to
majordomo(at)postgresql(dot)org)

__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Eckermann 2001-12-27 17:16:17 Re: Migrate Store Procedure Sybase to PostgreSQL
Previous Message Joe 2001-12-27 15:01:16 Filtering a bunch of records to one after a selection has returned a bunch of them