Danish Habib

Danish Habib

  • NA
  • 694
  • 242.8k

Database Records are duplicated

Jan 26 2015 6:52 AM
Dear I have made tables like that 

user(UserID(P),USerName,Email,Password)
DistrictUsers(DistrictID(P),DistrictName,UserID(F))
TehsilUsers(TehsilID(P),TehsilName,DistrictID(F),USERID(F))
UCSUSERS(UCID(P),UCNAME,TehsilID(F),USERID(F))
VILLAGESUSER(VillageID(P),VillageName,UCID(F),USERIF(F))





on Gridview editing below is my code 


SELECT  U.UserId,U.[Address],U.City,u.Country,UT.TehsilId,UC.UCID ,UC.UCName,UV.VillageId ,UV.VillageName  ,UT.TehsilName,U.DistrictId,UD.DistrictName ,UD.DistrictId ,UD.UserId,U.FullName,U.IPAddress,U.IsActive,U.IsAdmin,U.IsPasswordReset,U.IsReportable,U.IsVisible,U.CreateDate ,U.Mobile,U.Password,U.ReporintPerson,U.SecurityAnswer,U.SecurityQuestion ,U.UserId,U.Email,U.UserTypes FROM Users  U
INNER JOIN UserDistricts  UD ON UD.UserId=U.UserId
INNER JOIN UserTehsils UT ON UT.UserID=U.UserId 
INNER JOIN UserUcs UC ON UC.UserID=U.UserId 
INNER JOIN UserVillages UV ON UV.UserId=U.UserId 
WHERE U.UserId  =7
I have 10 users into the user table 
And I have one record in DistrictUser table
three records in TehsilUSers table
23 Reoords in UCSUSERS table
53 Records in VillagesUsers table

it return 3657 Rows Tell me please the mistake in the above query 

Answers (1)