From: | Kevin Grittner <kgrittn(at)ymail(dot)com> |
---|---|
To: | Tim Uckun <timuckun(at)gmail(dot)com> |
Cc: | Tony Theodore <tony(dot)theodore(at)gmail(dot)com>, Alban Hertroys <haramrae(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Why is this a cross join? |
Date: | 2013-02-18 23:05:24 |
Message-ID: | 1361228724.57214.YahooMailNeo@web162901.mail.bf1.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Tim Uckun <timuckun(at)gmail(dot)com> wrote:
>> how do you want to determine which of the matching rows in the
>> other table to choose, and which to ignore?
>
> Any of the matching rows will do but I just want one.
Well, if you don't care, this might give you what you want.
select distinct on (x.first6) crm.*, x.*
from from sap_crm_sales crm
join (select left(mc.sap_code,6) as first6, mc.*
from model_configurations mc) x
on x.first6 = left(crm.customer_class, 6)
order by x.first6;
I can think of about a dozen different things which fit the
description that you've given so far that you *might* want instead,
but unless you get more specific we can only guess.
If this isn't what you want, your best bet might might be to come
up with a self-contained example, where you create an populate
tables with a small amount of data, and show what you would like as
a result given that data set.
--
Kevin Grittner
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From | Date | Subject | |
---|---|---|---|
Next Message | komunca | 2013-02-18 23:59:07 | PgBouncer with many databases |
Previous Message | Joe Van Dyk | 2013-02-18 23:05:05 | subselects vs WITH in views |