Re: SELECT question (splitting a field)

From: Richard Huxton <dev(at)archonet(dot)com>
To: Madison Kelly <linux(at)alteeve(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: SELECT question (splitting a field)
Date: 2007-09-04 19:51:02
Message-ID: 46DDB726.3000206@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Madison Kelly wrote:
> nmc=> SELECT 'Y' AS local FROM domains WHERE '@'||dom_name IN
> ('mkelly(at)test(dot)com');
> local
> -------
> (0 rows)
>
> Not work?

I don't think IN does what you think it does. It's not a substring-test,
but a set test:

SELECT 1 WHERE 'x' IN ('a','b','c','x');
SELECT a FROM foo WHERE b IN (SELECT z FROM bar WHERE frozzled<>wamble);

You could mess around with substring() and length() or I'd use LIKE.

If it's just a domain you're looking for though, might be most efficient
to strip the leading part off your value with regexp_replace().

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Madison Kelly 2007-09-04 19:54:51 Re: SELECT question (splitting a field)
Previous Message Scott Marlowe 2007-09-04 19:49:08 Re: SELECT question (splitting a field)