Re: [GENERAL] Why is this a cross join?

2013-02-18 Thread Kevin Grittner
Tim Uckun 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

Re: [GENERAL] Why is this a cross join?

2013-02-18 Thread Tim Uckun
> for every row in one of the tables? If so, how do you want to > determine which of the matching rows in the other table to choose, > and which to ignore? In this case it's a simple lookup. Any of the matching rows will do but I just want one. -- Sent via pgsql-general mailing list (pgsql-ge

Re: [GENERAL] Why is this a cross join?

2013-02-18 Thread Kevin Grittner
Tim Uckun wrote: > I guess I am not explaining it properly.. > > Say I created new columns on both tables called "first_6" and > populated them with the substrings.  If I did a inner join or a > left join on those fields would I still get a cross join? > > inner join model_configurations mc on mc

Re: [GENERAL] Why is this a cross join?

2013-02-17 Thread John R Pierce
On 2/17/2013 2:09 PM, Tim Uckun wrote: Say I created new columns on both tables called "first_6" and populated them with the substrings. If I did a inner join or a left join on those fields would I still get a cross join? inner join model_configurations mc on mc.first_6 = crm.first_6 without

Re: [GENERAL] Why is this a cross join?

2013-02-17 Thread Tony Theodore
On 18/02/2013, at 9:09 AM, Tim Uckun wrote: >> >> In some way, every join is a cross join, with the results filtered according >> to the specificity of the join conditions. In this case: >> >> inner join model_configurations mc on left(crm.customer_class, 6) = >> left(mc.sap_code,6) >> >> "

Re: [GENERAL] Why is this a cross join?

2013-02-17 Thread Adrian Klaver
On 02/17/2013 02:09 PM, Tim Uckun wrote: In some way, every join is a cross join, with the results filtered according to the specificity of the join conditions. In this case: inner join model_configurations mc on left(crm.customer_class, 6) = left(mc.sap_code,6) "customer_class" sounds like

Re: [GENERAL] Why is this a cross join?

2013-02-17 Thread Tim Uckun
> > In some way, every join is a cross join, with the results filtered according > to the specificity of the join conditions. In this case: > > inner join model_configurations mc on left(crm.customer_class, 6) = > left(mc.sap_code,6) > > "customer_class" sounds like a fairly generic sort of field

Re: [GENERAL] Why is this a cross join?

2013-02-17 Thread Tony Theodore
On 18/02/2013, at 7:58 AM, Tim Uckun wrote: >> Apparently the first 6 characters of those fields are quite common, which >> gives you a result for every possible combination of the same 6-character >> value. > > > M. That seems kind of weird. Is there any way to NOT have this > be a cros

Re: [GENERAL] Why is this a cross join?

2013-02-17 Thread Tim Uckun
> Apparently the first 6 characters of those fields are quite common, which > gives you a result for every possible combination of the same 6-character > value. M. That seems kind of weird. Is there any way to NOT have this be a cross join? For example if I extracted the first six characte

Re: [GENERAL] Why is this a cross join?

2013-02-17 Thread Alban Hertroys
On Feb 17, 2013, at 9:16, Tim Uckun wrote: > I have a seemingly simple query that returns way too many records. > Here is the count query > > select count(*) from ( >select crm.* >from sap_crm_sales crm > inner join model_configurations mc on left(crm.customer_class, 6) > = left(mc.s

[GENERAL] Why is this a cross join?

2013-02-17 Thread Tim Uckun
I have a seemingly simple query that returns way too many records. Here is the count query select count(*) from ( select crm.* from sap_crm_sales crm inner join model_configurations mc on left(crm.customer_class, 6) = left(mc.sap_code,6) ) as s The crm table has about 44K records, th