samedi 21 février 2015

How to take data from two tables,one table not having common record

Please Help I got a problem with join in my sqlite database,In that I 'm having two tables like userdetails and usertransaction tables,


userdetails having 5 records like userids 1,2,3,4,5 with their details


and 2nd table usertransaction having only 1 and 2 records.


I want to take userdetails with taht user trasactions sum... if no transactions simply replace zero and remaing details. please help me...


query like this...


Select tblfarmers .farmerid,tblfarmers .farmerName,tblfarmers .mobileNumber,tblfarmers .Address ,SUM(IfNULL(tblFarmerAdvanceDetails.presentadvance, 0)) as presentadvance


from tblfarmers left join tblFarmerAdvanceDetails on tblFarmerAdvanceDetails.farmerid=tblfarmers .farmerid where tblfarmers .farmerid='2' and tblFarmerAdvanceDetails.isactive='true' ORDER BY tblfarmers .farmerid


Aucun commentaire:

Enregistrer un commentaire