On Fri, 14 Sep 2001, Philippe Parmentier wrote:

> > as per the manual, when joining 2 tables, if one entry is not found in the
> > second table , a null records is displayed, but in that small example,
> > it's not working like this:


Philippe,

the very fine manual says:

   * If there is no matching record for the right table in the `ON' or
     `USING' part in a `LEFT JOIN', a row with all columns set to
     `NULL' is used for the right table.

while you are doing a full join. MySQL behaves exactly as
described and expected.

Thomas Spahni


> > CREATE TABLE test1 (
> >   number tinyint(3) unsigned NOT NULL DEFAULT '0' ,
> >   PRIMARY KEY (number));
> > 
> > INSERT INTO test1 VALUES("1");
> > INSERT INTO test1 VALUES("2");
> > INSERT INTO test1 VALUES("3");
> > 
> > CREATE TABLE test2 (
> >   number tinyint(3) unsigned NOT NULL DEFAULT '0' ,
> >   cnumber char(10) NOT NULL DEFAULT '' ,  PRIMARY KEY (number)
> > );
> > 
> > INSERT INTO test2 VALUES("1","one");
> > INSERT INTO test2 VALUES("2","two");
> > 
> > if you do :
> > 
> > select test1.number,test2.cnumber from test1,test2 where
> > test1.number=test2.number
> > 
> > 
> > the result is
> > 
> > number      cnumber
> >           1 one
> >           2 two
> > 
> > 
> > instead of
> > 
> > number cnumber
> >           1 one
> >           2 two
> >           3
> > 
> > Regards
> > 
> > Philippe Parmentier


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to