Search Postgresql Archives

Re: SELECT question (splitting a field)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx');

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@xxxxxxxx' in 'dom_name'?

Something like:

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

--
  Richard Huxton
  Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux