Re: Why is this a cross join?

From: Kevin Grittner <kgrittn(at)ymail(dot)com>
To: Tim Uckun <timuckun(at)gmail(dot)com>, Tony Theodore <tony(dot)theodore(at)gmail(dot)com>
Cc: 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 16:41:25
Message-ID: 1361205685.67194.YahooMailNeo@web162906.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:

> 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.first_6 = crm.first_6

As others have said, that would not change the results -- you are
getting exactly what you are requesting, but apparently not what
you want.  Can you explain what it is that you do want?  If you
have ten rows in one table with the same "first six" value, and 20
rows in the other table with that same "first six" value, how do
you want them to be matched up?  Do you want one row in the result
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?

--
Kevin Grittner
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Denis Papathanasiou 2013-02-18 16:53:57 How to index xml type column queries effectively?
Previous Message Magnus Hagander 2013-02-18 16:21:19 Re: could not link file "pg_xlog/xlogtemp.72606"