Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have 2 table :
SQL
tbl_1 :

TypeID(pk)    Product         Type
 
1         ELectronic      Online            
2         Health          Offline                                       
3         Cloth           Online 

SQL
tbl_2 :
ID(pk)    Name         TypeID(fk)
 
1         Akon           1            
2         Nancy          3                                       
3         Sam            1 
4         John           2            
5         Rack           3 


From above two queries I need data which shows Type on the basis of TypeID, See below:
XML
Result :
ID         Name         TypeID  Type

1         Akon           1         Online
2         Nancy          3         Online
3         Sam            1         Online
4         John           2         Offline
5         Rack           3         Online 


Any suggestion really appreciate :
Posted
Updated 15-Apr-13 20:55pm
v2
Comments
1989priya 16-Apr-13 3:17am    
select a.type,b.ID,b.Name,b.TypeID from tbl_1 a innerjoin tbl_2 b on tab1id=tab2ID

Try this:
SQL
SELECT a.*, b.*
FROM table1 AS a INNER JOIN table2 AS b ON a.typeid = b.typeid
 
Share this answer
 
v2
Comments
Mas11 16-Apr-13 2:54am    
Thanks for the answer, but it doesn't work.
Maciej Los 16-Apr-13 2:57am    
What doesn't work?
SQL
select tbl_2.*, tbl_1.[Type]
from tbl_2 
Inner join tbl_1 on tbl_2.TypeId = tbl_1.TypeId

Happy Coding!
:)
 
Share this answer
 
Comments
Mas11 16-Apr-13 3:23am    
Thanks ! Its mine answer. :)
Aarti Meswania 16-Apr-13 3:25am    
Welcome!
Glad to help you! :)

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