Skip navigation links

MySQL Forums :: MySQL Query Analyzer :: join


Advanced Search

join
Posted by: Kelly Brace ()
Date: January 03, 2012 01:12AM

Hello,
I am working on a join with 2 tables.
payments and dbase

columns I want from payments:
assignedto, paymentamount

payments and dbase have filenumber to join on.

I want to select assignedto, sum(paymentamount) from payments where dbase.statusname!='NSF';

This is what I have that works for payments without the join:

select p.assignedto,sum(p.paymentamount) from payments p where paymentdate between '2012-01-01 00:00:00' and '2012-01-31 00:00:00' and paymentstatus='PENDING' group by p.assignedto;


When I attempt to join, it seems to hang forever (possible cartesian):

select p.assignedto,sum(p.paymentamount) from payments p, dbase d where p.filenumber=d.filenumber and d.statusname!='NSF' and paymentdate between '2012-01-01 00:00:00' and '2012-01-31 00:00:00' and paymentstatus='PENDING' group by p.assignedto;

Any advice/help would be greatly appreciated. Thanks in advance.

Options: ReplyQuote


Subject Views Written By Posted
join 1253 Kelly Brace 01/03/2012 01:12AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.