SELECT DISTINCT
        table1.column1,
        table1.column3,
        table2.column1,
        table2.column2,
        table3.column3,
        table3.column4
FROM
        (table1LEFT JOIN table2 ON table1.column1=table2.column1)
        LEFT JOIN table3 ON table1.column3=table3.column3;

you can add more tables like this...

regds,
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, March 21, 2003 04:51
To: mysql
Subject: (left?) join across multiple tables to one table


I'm not sure if a LEFT JOIN is the proper way of doing
the following to join two tables to one table (table2
and table3 to columns in table1).

Currently, I have no problems joining table2 to table1
through the following SELECT statement:

SELECT DISTINCT
table1.column1,
table2.column1,
table2.column2
FROM table1
LEFT JOIN table2
USING (column1);

What would be the expansion of this to I can add
table3 to this SELECT statement and have (for example)
table1.column3 = table3.column3?

Although the following SELECT statement is not
correct, it would logically do something like the
following:

SELECT DISTINCT
table1.column1,
table1.column3,
table2.column1,
table2.column2,
table3.column3,
table3.column4
FROM table1
LEFT JOIN table2
USING (column1)
AND (pseudocode follows:)
FROM table1
LEFT JOIN table3
USING (column3);

mysql

__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com


---------------------------------------------------------------------
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