Re: Howto make a double LEFT JOIN

From: Date: Tue, 02 Oct 2001 20:37:54 +0000
Subject: Re: Howto make a double LEFT JOIN
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-12937@lists.php.net to get a copy of this message
> SELECT table1.id FROM table1 LEFT JOIN table2 ON table1.id=table2.id LEFT > JOIN table3 ON table2.id=table3.id Well, oke now i have: table1: id|no 1|1 2|1 table2: id|no 1|1 1||1 table2: id|no 1|1 1||1 1||1 The result i want tot have is: id|sum(table2.no)|sum(table3.no)| 1|2|3 2|0|0 my query: SELECT DISTINT( table1.id) AS test, SUM(table2.no) AS tot, SUM(table3.no FROM table1 LEFT JOIN table2 ON table1.id=table2.id LEFT JOIN table3 ON table2.id=table3.id GROUP BY test ORDER BY tot DESC which give my something like: id|5|5| 1|2|3 2|0|0 :( ----- Original Message ----- From: "Rick Emery" <remery@excel.com> To: "'Bas Jobsen'" <bas@startpunt.cc>; <php-db@lists.php.net> Sent: Tuesday, October 02, 2001 10:19 PM Subject: RE: [PHP-DB] Howto make a double LEFT JOIN > SELECT table1.id FROM table1 LEFT JOIN table2 ON table1.id=table2.id LEFT > JOIN table3 ON table2.id=table3.id > > -----Original Message----- > From: Bas Jobsen [mailto:bas@startpunt.cc] > Sent: Tuesday, October 02, 2001 3:13 PM > To: Rick Emery; php-db@lists.php.net > Subject: Re: [PHP-DB] Howto make a double LEFT JOIN > > > > Remove the parentheses > > SELECT table1.id FROM table1 LEFT JOIN table2 LEFT JOIN table3 ON > > table2.id=table3.id ON table1.id=table2.id > > I still got: > MySQL retourneerde: You have an error in your SQL syntax near 'LEFT JOIN > table3 ON > table2.id=table3.id ON table1.id=table2.id' at line 1 > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.db (#12937) next »