Click here to Skip to main content
15,884,642 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
There are two tables tblUser and tblHelpAndSupport and the database is SQL server 2005. They have no common field. UserId is the primary key of tblUser. But tblHelpAndSupport doesn't contain UserId. I have to retrieve all data from tblHelpAndSupport where the condition is UserId='001' in tblUser table. How can I retrieve data on the above condition?
Posted
Updated 5-Jun-13 19:58pm
v3
Comments
Ron Beyer 6-Jun-13 0:17am    
There's a million ways, but we can't give you any of them if you don't give us more information. What are you trying to select from help and support, what are you going to use as a join parameter, what is the schema of your tables? On top of that, what kind of database?
Sumon562 6-Jun-13 3:07am    
Can you please explain some of the ways? I will be gratful to you
Suvabrata Roy 6-Jun-13 0:39am    
Please elaborate your question

1 solution

It's as easy as
SQL
Select columnsYouWantFromBothTables
From tblUser , tblHelpAndSupport
Where tblUser.UserId = '001'


You don't have to specify a join - it will retrieve the single row from User and all orws from HelpAndSupport
 
Share this answer
 
Comments
Sumon562 6-Jun-13 2:07am    
Thank you Mr. _Maxxx_. If I want to retrieve only one row then is it possible?
_Maxxx_ 6-Jun-13 2:12am    
But which row?

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