Click here to Skip to main content
16,019,876 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Following is my query which is not displaying any result. Please help me out.
SQL
select * from tblPersonalDetails Inner Join tblFamilyDetails on tblPersonalDetails.Email=tblFamilyDetails.Email
Inner Join tblImageDetails on tblPersonalDetails.Email=tblImageDetails.Email
Inner Join tblEducationalDetails on tblPersonalDetails.Email=tblEducationalDetails.Email
Inner Join tblAcademicDetails on tblPersonalDetails.Email=tblAcademicDetails.Email
Inner Join tblWorkExpDetails on tblPersonalDetails.Email=tblWorkExpDetails.Email
Inner Join tblReferenceDetails on tblPersonalDetails.Email=tblReferenceDetails.Email
Inner Join tblDeclarationDetails on tblPersonalDetails.Email=tblDeclarationDetails.Email where (tblPersonalDetails.FirstName like '%' + @search + '%' )
Posted
Updated 17-Mar-15 1:57am
v2
Comments
ZurdoDev 17-Mar-15 7:40am    
There is no way we can know why no data is showing. We can't see your database. However, INNER JOIN means the record must exist in each table. Perhaps start changing the INNER to LEFT and then you'll see which one of the subs has no records.
Member 11304660 17-Mar-15 7:54am    
thanks. It worked when i changed inner join to left join
Maciej Los 17-Mar-15 8:00am    
Does it solve your issue? If yes, you shoould ask RyanDev to post his comment as an answer and accept it (green button).

As mentioned in the comments, you can change your INNER to LEFT and see which join is causing everything to fall out.

However, you don't want to just change everything from INNER to LEFT without understanding what you are doing.

When you join a table using INNER it means that there must be a match. So, for example, if you INNER JOIN tblReferenceDetails and there is no matching record in tblReferenceDetails then you will get no results. This may be what you want. Or, you may not care that there is no matching record in tblReferenceDetails and in that case you use a LEFT join. If there is a matching record, you can pull it's columns otherwise they will be NULL.

So, you need to decide for each JOIN to use the correct type, don't just change INNER to LEFT blindly.
 
Share this answer
 
Comments
[no name] 17-Mar-15 12:10pm    
Thorough answer, 5ed.
ZurdoDev 17-Mar-15 12:14pm    
Thank you.
I would take off there WHERE clause and see if your query brings get anything back. If you get a lot of records back, I'd then focus my attention to the WHERE clause and use returns items in your WHERE clause.
 
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