Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my first query is not working and second is working but i want to search a member through group id


SQL
select m.mId,(mFName+' '+isnull(mLName,'')) as mname,s.subCatName,s.subCatId,
 mAdd,
   mContact,mCity,mFather,mQual from tblMemberDetail m
 inner join tblMemberCourse c on m.mId=c.mId
 inner join tblSubCategory s on c.subcatId=s.subCatId
 where mActive = 1 and m.mId=1



SQL
select m.mId,(mFName+' '+isnull(mLName,'')) as mname,
g.gName, mAdd,
   mContact,mCity,mFather,mQual from tblMemberDetail m
 inner join tblMemberCourse c on m.mId=c.mId
 inner join tblGroup g on c.gId=g.gId
 where mActive = 1 and m.mId=1
Posted
Updated 19-Dec-12 20:47pm
v4
Comments
__TR__ 20-Dec-12 2:57am    
What do you mean by "not working" ? Are you getting any error ?
We need some more details on what is it you are trying to do.
ZeroCoding 20-Dec-12 3:13am    
Have you checked that the subcatId returned by tblMemberCourse actually exists in tblSubCategory?

More info

1 solution

Hi,

Both the Query are ok ,

In case if Query is not returning any row then possible reason is that
tblSubcategory don't have record for MemberID : 1 ;

you may use left join in such case as

SQL
select m.mId,(mFName+' '+isnull(mLName,'')) as mname,s.subCatName,s.subCatId,
 mAdd,
   mContact,mCity,mFather,mQual from tblMemberDetail m
 inner join tblMemberCourse c on m.mId=c.mId
 left join tblSubCategory s on c.subcatId=s.subCatId
 where mActive = 1 and m.mId=1


Thanks !
Yogendra Dubey
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900