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
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

Pradeep ShetPosted Jan 27, 2015, 5:22 AM
This will definitely give you the wiered result. IS it that 23 records or 53 records for each users or total 23 records in UCSUSERS table?
If it is for each users then the result is proper. you need to modify the query.