dbTalk Databases Forums  

Join query problem with mysql

comp.databases.mysql comp.databases.mysql


Discuss Join query problem with mysql in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
amvis
 
Posts: n/a

Default Join query problem with mysql - 12-13-2011 , 07:37 AM






i have two tables, customer and transaction.Both have primary key as id.The customer table have one field created_at. and the transaction table have one field points.

I need to take the sum(points) from transaction but that will be the created_at > "2010-12-11". But query gives error.....

how will take this using join....?

Reply With Quote
  #2  
Old   
Erick T. Barkhuis
 
Posts: n/a

Default Re: Join query problem with mysql - 12-13-2011 , 07:50 AM






amvis:

Quote:
i have two tables, customer and transaction.Both have primary key as
id.The customer table have one field created_at. and the transaction
table have one field points.

I need to take the sum(points) from transaction but that will be the
created_at > "2010-12-11". But query gives error.....
What query? What error? How do customer and transaction tables relate?

Quote:
how will take this using join....?
Do you want the sum of all points of all customers that were created
after Dec.11, 2010?

SELECT sum(points) AS totalpoints
FROM transaction
INNER JOIN customer ON customer.id=transaction.cid
WHERE created_at > "2010-12-11"

assuming that transaction.cid is foreign key for customer.id



--
Erick

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.