need help with joins

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
nikko50
Forum Commoner
Posts: 43
Joined: Thu Apr 08, 2004 6:28 am

need help with joins

Post by nikko50 »

I'm trying to join 2 tables for a query. The query will summarize all items shipped and all items received regardless of quantity. I have 2 tables one called shipped and one called receive. Each table contains an equipment field and a quantity field. The code below does not work well because it does not return the correct quantities shipped or received for each individual equipment. In both tables there is duplicate records for equipment shipped or equipment received. I need help on this cause I have no idea how to summarize the two tables.


$equiplist= "select receive.equipment, sum(receive.quantity) as 'receivedsum', sum(shiplist.quantity) as 'shippedsum'
from receive
left join shiplist on shiplist.equipment = receive.equipment
group by receive.equipment";
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

For others reading this, it's (also) being discussed in viewtopic.php?t=21030
Post Reply