Re: [SQL] Help writing a piece of SQL

2006-02-03 Thread Niklas Johansson
On 3 feb 2006, at 14.06, Nigel Bishop wrote: Thank you very much, that did the business This should generate the same plan as the previous query, but be a little bit more clean and easy to read: SELECT sendto FROM users t1 WHERE domain='rusty.com' AND username = COALESCE((SELECT username

Re: [SQL] Help writing a piece of SQL

2006-02-03 Thread Nigel Bishop
Niklas, Thank you very much, that did the business Cheers Nigel Bishop -Original Message- From: Niklas Johansson [mailto:[EMAIL PROTECTED] Sent: 03 February 2006 13:00 To: Nigel Bishop Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Help writing a piece of SQL On 3 feb 2006, at

Re: [SQL] Help writing a piece of SQL

2006-02-03 Thread Niklas Johansson
On 3 feb 2006, at 11.43, Nigel Bishop wrote: 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=

Re: [SQL] Help writing a piece of SQL

2006-02-03 Thread Nigel Bishop
Bishop ioko T: +44 (0)1904 435 458 M: +44 (0)7881 624 386 F: +44 (0)1904 435 450 E: [EMAIL PROTECTED] W: www.ioko.com -Original Message- From: Richard Huxton [mailto:[EMAIL PROTECTED] Sent: 03 February 2006 11:02 To: Nigel Bishop Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Help

Re: [SQL] Help writing a piece of SQL

2006-02-03 Thread Richard Huxton
Nigel Bishop wrote: username |domain |sendto +-+---+- - Postmaster | intthit08.uk.rabbit.com | root root | intthit08.uk.rabbit.com | [EMAIL PROTECTED] stoat.grif

[SQL] Help writing a piece of SQL

2006-02-03 Thread Nigel Bishop
Hi, I would appreciate some help writing a piece of SQL   PG803   My table/data looks like this:   username |    domain     |    sendto    +-+---+--  Postmaster   | intthit0