Waldemar Dymkiewicz pisze:
Moze to zadziala ;) Dopisalem z palca tylko SUM, nie sprawdzale co to daje.
SELECT customers.id, customers.lastname, customers.name, customers.address, customercontacts.phone, SUM(cash.value) FROM customers LEFT JOIN customercontacts ON (customers.id=customercontacts.id) JOIN cash ON (customers.id=cash.customerid) ORDER BY lastname;
mysql> SELECT customers.id, customers.lastname, customers.name, customers.address, customercontacts.phone, SUM(cash.value) FROM customers LEFT JOIN customercontacts ON (customers.id=customercontacts.id) JOIN cash ON (customers.id=cash.customerid) ORDER BY lastname; +----+------------+--------+----------+-------+-----------------+ | id | lastname | name | address | phone | SUM(cash.value) | +----+------------+--------+----------+-------+-----------------+ | 1 | SIARKOWSKI | Tomasz | Byto? 10 | NULL | -12610.00 | +----+------------+--------+----------+-------+-----------------+ 1 row in set (0.00 sec)
daje w wyniku jeden rekord z klientem o pierwszym id a w cash suma dla wszystkich klientow
!DSPAM:4861dfaf236971436614547!