Re: Wildcard LIKE and Sub-select

From: "Travis Whitton" <tinymountain(at)gmail(dot)com>
To: "Erik Jones" <erik(at)myemma(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Wildcard LIKE and Sub-select
Date: 2006-11-10 16:07:44
Message-ID: cf9b4f3e0611100807wc1acc57xdd65944e3cd54bda@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I took off the USING clause like so, and it worked like a charm!

DELETE FROM keywords
WHERE keyword ILIKE ANY (SELECT '%' || badword || '%'
FROM badwords)

Thanks so much,
Travis

On 11/10/06, Erik Jones <erik(at)myemma(dot)com> wrote:
>
> Travis Whitton wrote:
> > Hi everybody,
> > I have two tables of the following structure:
> >
> > Table "keywords"
> >
> > column | type
> > ---------------------
> > id | integer
> > keyword | varchar(255)
> >
> > and
> >
> > Table "badwords"
> >
> > column | type
> > ----------------------
> > badword | varchar(255)
> >
> >
> > I need to delete all the rows from the keywords table where badword
> > partially matches the keyword field. I know I can do an exact match
> > with a sub-select, but I'm not sure how to structure a wildcard match
> > / like clause with a sub-select. Also, is that the best way to do it,
> > or should I be looking into full-text? I have roughly 10 million
> > keywords and 1 million badwords.
> >
> > Thanks,
> > Travis
> >
> Hmm... Maybe (this is untested):
>
> DELETE FROM keywords
> USING badwords
> WHERE keyword ILIKE ANY (SELECT '%' || badword || '%'
> FROM badwords)
>
> --
> erik jones <erik(at)myemma(dot)com>
> software development
> emma(r)
>
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Wm.A.Stafford 2006-11-10 16:10:22 PostgesSQL equivalent of the Oracle 'contains' operator
Previous Message Erik Jones 2006-11-10 16:01:10 Re: Wildcard LIKE and Sub-select