Dawood Abbas

Dawood Abbas

  • NA
  • 264
  • 95.2k

Data Retrieve from two parent and three child tables

Feb 25 2015 7:51 AM
I have 'C_Register(Cid,Cname,Eid,Aid,PackId...)',  'R_Pay(Pid,Cid,Eid,PackId,Aid.....)', 'Area(Aid,AreaName)', 'Package(PackId, PackName), Emp(Eid,Ename)
 
want to retrieve like this
 
Select C_Register.CId,C_Register.Name,C_Register.UserName,C_Register.Status,
Packages.PackagePeriod,Packages.PackageName,C_Register.ActivationDate,
Receive_Payment.OldExpiryDate,Receive_Payment.Balance,Receive_Payment.PyingAmount,
Receive_Payment.LastPaidDate,C_Register.LastUpdateTime,Area.AreaName,
C_Register.MobNo,Employee.EmpName,C_Register.Address,C_Register.CreatedDate
 
 I joined like this..
 
from C_Register
Join Packages on C_Register.PackId=Packages.PackId
Join Receive_Payment on C_Register.CId=Receive_Payment.CId
Join Area on C_Register.AId=Area.AId
Join Employee on C_Register.EId=Employee.EId
 
But getting double row from  C_Register like below
 
101 MohammedDawood dawood507 NULL Monthly Three Hundred (Package) 2015-02-16 NULL 0 300 NULL NULL TowliChowki +919000959239 Basith 3-4-145 NULL
112 Bakhtiyar Bakhtiyar786 NULL Monthly Three Hundred (Package) 2015-02-19 2015-03-19 0 0 2015-02-19 NULL TowliChowki +919000000000 Basith 2-40-52 2015-02-19
112 Bakhtiyar Bakhtiyar786 NULL Monthly Three Hundred (Package) 2015-02-19 2015-04-19 0 400 2015-02-24 NULL TowliChowki +919000000000 Basith 2-40-52 2015-02-19
 
where I want just
 
 
101 MohammedDawood dawood507 NULL Monthly Three Hundred (Package) 2015-02-16 NULL 0 300 NULL NULL TowliChowki +919000959239 Basith 3-4-145 NULL
112 Bakhtiyar Bakhtiyar786 NULL Monthly Three Hundred (Package) 2015-02-19 2015-03-19 0 0 2015-02-19 NULL TowliChowki +919000000000 Basith 2-40-52 2015-02-19
 
 
 
so how to to join? 

Answers (1)