From: | "Nigel Bishop" <Nigel(dot)Bishop(at)ioko(dot)com> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Help writing a piece of SQL |
Date: | 2006-02-03 10:43:23 |
Message-ID: | 72558D9A7573814BB4082A28843E03D402658B02@intyodc01.uk.ioko365.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi, I would appreciate some help writing a piece of SQL
PG803
My table/data looks like this:
username | domain | sendto
+-------------+-------------------------------+-------------------------
-----
Postmaster | intthit08.uk.rabbit.com | root
root | intthit08.uk.rabbit.com | is-unix(at)rabbit(dot)com
stoat.griffin | trusting.co.uk | stoat(dot)griffin(at)rabbit(dot)com
stoat.griffin | trusting.com | stoat(dot)griffin(at)rabbit(dot)com
stoat.griffin | rusty.co.uk | stoat(dot)griffin(at)rabbit(dot)com
stoat.griffin | rusty.com | stoat(dot)griffin(at)rabbit(dot)com
matilda.clematis | trusting.com |
matilda(dot)clematis(at)rabbit(dot)com
matilda.clematis | trusting.co.uk |
matilda(dot)clematis(at)rabbit(dot)com
matilda.clematis | rusty.co.uk |
matilda(dot)clematis(at)rabbit(dot)com
matilda.clematis | rusty.com |
matilda(dot)clematis(at)rabbit(dot)com
* | trusting.com | rusty(at)rabbit(dot)com
* | trusting.co.uk | rusty(at)rabbit(dot)com
* | rusty.co.uk | rusty(at)rabbit(dot)com
* | rusty.com | rusty(at)rabbit(dot)com
* | windoze.com | windoze(at)badger(dot)com
* | windoze.co.uk | windoze(at)badger(dot)com
admin | windoze.co.uk |
matilda(dot)clematis(at)rabbit(dot)com
admin | windoze.com |
matilda(dot)clematis(at)rabbit(dot)com
* | saxon.co.uk | superR(at)uk(dot)diamond(dot)com
* | saxon.com | superR(at)uk(dot)diamond(dot)com
The query will have the username and domain passed in as variables.
If the username and domain exist then return the sendto
The bit I'm struggling with is if the username doesn't exist then return
the sendto where the domain exists
e.g. username=fred (this doesn't exist) and domain=rusty.com then
return rusty(at)rabbit(dot)com, matilda(dot)clematis(at)rabbit(dot)com,
stoat(dot)griffin(at)rabbit(dot)com
Any help on this would very much appreciated; it's been driving me mad
for the last day.
Thanks
Nigel
Communications on or through ioko's computer systems may be monitored or recorded to secure effective system operation and for other lawful purposes.
Unless otherwise agreed expressly in writing, this communication is to be treated as confidential and the information in it may not be used or disclosed except for the purpose for which it has been sent. If you have reason to believe that you are not the intended recipient of this communication, please contact the sender immediately. No employee is authorised to conclude any binding agreement on behalf of ioko with another party by e-mail without prior express written confirmation.
ioko365 Ltd. VAT reg 656 2443 31. Reg no 3048367. All rights reserved.
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2006-02-03 11:01:34 | Re: Help writing a piece of SQL |
Previous Message | Ragnar | 2006-02-03 09:27:11 | Re: CREATE INDEX with order clause |