From: | Alvaro Herrera <alvherre(at)atentus(dot)com> |
---|---|
To: | Chris Bowlby <excalibur(at)hub(dot)org> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Query having issues... |
Date: | 2002-09-13 14:57:39 |
Message-ID: | Pine.LNX.4.44.0209131052030.2059-100000@cm-lcon1-46-187.cm.vtr.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
Chris Bowlby dijo:
> SELECT co.first_name, co.last_name, co.email_address,
> a.password, c.company_number
> FROM contact co, domain d
> LEFT JOIN account_info a ON (co.contact_id = a.contact_id)
> LEFT JOIN company c ON (co.company_id = c.company_id)
> WHERE d.domain_id = '666'
> AND d.company_id = co.company_id;
Note that you are JOINing "domain d" with "account_info a"; by the time
this is looked up, there is no relation co there, so the qualification
doesn't make sense. Try this:
SELECT co.first_name, co.last_name, co.email_address,
a.password, c.company_number
FROM domain d, contact co
LEFT JOIN account_info a ON (co.contact_id = a.contact_id)
LEFT JOIN company c ON (co.company_id = c.company_id)
WHERE d.domain_id = '666'
AND d.company_id = co.company_id;
--
Alvaro Herrera (<alvherre[a]atentus.com>)
"Now I have my system running, not a byte was off the shelf;
It rarely breaks and when it does I fix the code myself.
It's stable, clean and elegant, and lightning fast as well,
And it doesn't cost a nickel, so Bill Gates can go to hell."
From | Date | Subject | |
---|---|---|---|
Next Message | pkubat | 2002-09-13 14:59:59 | Case (in)-sensitivity & preserving case |
Previous Message | Carmen Wai | 2002-09-13 14:51:37 | Size of database |
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2002-09-13 15:06:17 | Re: Multicolumn foreign keys need useless unique indices? |
Previous Message | Stephan Szabo | 2002-09-13 14:50:19 | Re: Multicolumn foreign keys need useless unique indices? |