>From 5.0.1, I get ...

e       c       b
1       1       1
2       2       2
3       3       3
NULL    NULL    4

PB
  ----- Original Message -----
  From: Ian Sales
  To: [EMAIL PROTECTED]
  Sent: Thursday, October 07, 2004 4:21 AM
  Subject: Can someone please explain this?


  During some training on SQL recently, the following occurred. No one can
  explain it.

  The training used five tables A, B, C , D and E, each with a single int
  column.

  Table A has column a with values 1, 2, 3, 4, 5
  Table B has column b with values 1, 2, 3, 4
  Table C has column c with values 1, 2, 3, 4, 5, 6
  Table D has column d with values 1, 2, 3, 4
  Table E has column e with values 1, 2, 3

  When running the following SQL...

  select * from E left join C on e = c right join B on e = b;

  we got the following results:

  +------+------+------+
  | e    | c    | b    |
  +------+------+------+
  |    1 |    1 |    1 |
  |    2 | NULL |    1 |
  |    3 | NULL |    1 |
  |    1 | NULL |    2 |
  |    2 |    2 |    2 |
  |    3 | NULL |    2 |
  |    1 | NULL |    3 |
  |    2 | NULL |    3 |
  |    3 |    3 |    3 |
  |    1 | NULL |    4 |
  |    2 | NULL |    4 |
  |    3 | NULL |    4 |
  +------+------+------+
  12 rows in set (0.00 sec)

  Common sense expects the number of rows returned to be four. So where's
  the Cartesian coming from?

  - ian



  --
  | Ian Sales                                 Broadband Solutions for |
  | Database Administrator                            Home & Business |
  | PlusNet plc                                   http://www.plus.net |
  + ----------- PlusNet - The Smarter Way to Internet ----------------+


  --
  MySQL General Mailing List
  For list archives: http://lists.mysql.com/mysql
  To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to