List:General Discussion« Previous MessageNext Message »
From:Martijn Tonies Date:August 9 2004 4:39pm
Subject:Re: Selecting data from 2 tables.
View as plain text  
That depends on your definition of a "join"...

I don't call it a join without a join condition. It gives you tableA * tableB
results - that's a carthesian product. Hardly a normal join.

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL Server.
Upscene Productions
http://www.upscene.com

  He does have a join. He has an *implied* INNER JOIN
(http://dev.mysql.com/doc/mysql/en/JOIN.html):   

  FROM pages, pdflog 

  What he is really missing is the WHERE clause that matches something from pages with
something from pdflog....    Without it he is requesting a Cartesian product of his
tables (every combination of each row from both tables). 

  I prefer to define my JOINS *explicitly*. It makes it harder to accidentally define
Cartesian products): 

  SELECT DISTINCT company 
  FROM pages 
  INNER JOIN pdflog 
  ON ...some condition goes here .... 
  ORDER BY company 

  Shawn Green
  Database Administrator
  Unimin Corporation - Spruce Pine 

  "Martijn Tonies" <m.tonies@stripped> wrote on 08/09/2004 11:38:31 AM:

  > Hi,
  > 
  > > God, I feel real stupid this morning and know I should know this. I have
  > > 2 tables in the same database and I'm trying to select distinct data from
  > > a row with the same name in each table.
  > >
  > > SELECT DISTINCT company FROM pages, pdflog ORDER BY company ASC
  > >
  > > I'm missing something I'm sure because it doesn't work.
  > 
  > Feel stupid again ;-)
  > 
  > Where's your JOIN?
  > 

Thread
Selecting data from 2 tables.Ed Curtis9 Aug
  • Re: Selecting data from 2 tables.Martijn Tonies9 Aug
    • Re: Selecting data from 2 tables.Ed Curtis9 Aug
    • Re: Selecting data from 2 tables.SGreen9 Aug
      • Re: Selecting data from 2 tables.Ed Curtis9 Aug
      • Re: Selecting data from 2 tables.Ed Curtis9 Aug
        • Re: Selecting data from 2 tables.SGreen9 Aug
          • Re: Selecting data from 2 tables.Ed Curtis9 Aug
            • Re: Selecting data from 2 tables.SGreen9 Aug
      • Re: Selecting data from 2 tables.Martijn Tonies9 Aug