View Single Post

   
  #4 (permalink)  
Old 04-09-2008, 07:20 PM
Richard Huxton
 
Posts: n/a
Default Re: SELECT question (splitting a field)

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

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Reply With Quote