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

From Richard Huxton
Subject Re: SELECT question (splitting a field)
Date
Msg-id 46DDBC25.4040003@archonet.com
Whole thread Raw
In response to Re: SELECT question (splitting a field)  (Madison Kelly <linux@alteeve.com>)
List 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@test.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@test.com' in 'dom_name'?

Something like:

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

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

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