Re: SELECT question (splitting a field) - Mailing list pgsql-general

From Richard Huxton
Subject Re: SELECT question (splitting a field)
Date
Msg-id 46DDB726.3000206@archonet.com
Whole thread Raw
In response to SELECT question (splitting a field)  (Madison Kelly <linux@alteeve.com>)
Responses Re: SELECT question (splitting a field)
List pgsql-general
Madison Kelly wrote:
> nmc=> SELECT 'Y' AS local FROM domains WHERE '@'||dom_name IN
> ('mkelly@test.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

pgsql-general by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: SELECT question (splitting a field)
Next
From: Madison Kelly
Date:
Subject: Re: SELECT question (splitting a field)