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 20:12:21
Message-ID: 46DDBC25.4040003@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Madison Kelly wrote:
> SELECT 'Y' AS local FROM domains d, users u WHERE u.usr_dom_id=d.dom_id
> AND u.usr_email||'@'||d.dom_name IN ('mkelly(at)test(dot)com');
>
> Though this may not be the most efficient. In my case, the 'usr_email'
> is the LHS of the '@' sign and 'dom_name' is the domain name. If I
> wanted to use (I)LIKE, how would I have matched just the domain section
> of 'mkelly(at)test(dot)com' in 'dom_name'?

Something like:

SELECT ... FROM domains d WHERE ('%@' || d.dom_name) LIKE 'mkelly(at)test(dot)com';

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2007-09-04 22:56:23 Re: UTF8 frustrations
Previous Message Michael Glaesemann 2007-09-04 20:01:33 Re: UTF8 frustrations