Info form 3 table

Hi there

Below is a statment that gets info from 2 tables, it brings back info
from Tablea based on whats in productslist

is it possible to chnage it so that it brings back info `tableA`, `TableB`
and `TableC`
at the same time?


Brian



SELECT p.prod_code, p.description, SUM(o.`ord` ) AS totalor, SUM(o.`del` )
AS totaldel, SUM(o.`total_cost_price` ) AS totalcost ,
SUM(o.`total_invoice_price` ) AS totalinvoice FROM productslist AS p LEFT
OUTER JOIN `tableA` AS o ON ( p.prod_code = o.prod_code ) WHERE o.stock_type
= "Allocated" GROUP BY p.prod_code ORDER BY p.prod_code
Peter Lewis [ Di, 03 Oktober 2006 13:50 ] [ ID #1487394 ]

Re: Info form 3 table

Brian wrote:

> Hi there
>
> Below is a statment that gets info from 2 tables, it brings back info
> from Tablea based on whats in productslist
>
> is it possible to chnage it so that it brings back info `tableA`, `TableB`
> and `TableC`
> at the same time?
>
>
> Brian
>
>
>
> SELECT p.prod_code, p.description, SUM(o.`ord` ) AS totalor, SUM(o.`del` )
> AS totaldel, SUM(o.`total_cost_price` ) AS totalcost ,
> SUM(o.`total_invoice_price` ) AS totalinvoice FROM productslist AS p LEFT
> OUTER JOIN `tableA` AS o ON ( p.prod_code = o.prod_code ) WHERE o.stock_type
> = "Allocated" GROUP BY p.prod_code ORDER BY p.prod_code

Well, as long as you have some sort of key value in TableB and TableC
(e.g. prod_code) then just add them as extra Joins.
Captain Paralytic [ Di, 03 Oktober 2006 17:18 ] [ ID #1487395 ]
PHP » alt.php.sql » Info form 3 table

Vorheriges Thema: MySQL Triggers question
Nächstes Thema: MySQL 5 -- "Invalid default value"?