SQLTeam.com | Weblogs | Forums

Joining 2 tables


#1

I have 2 table Temp_Model,Txt_Temp. in Temp_Model i have ModelCodel and Modelname
and Txt_Temp ModelCode and should get result with ModelName with respect to Model Code.
below i have given details of table.
Thanks.

[B]Temp_Model[/B]		
Model_Id	Model_Code	Model_Name
    1	             IHA	           Mohavi
    2	             A7F	           Credenza
    3	             MJK	           Picanto
		
[B]Txt_Temp[/B]		
Model_Code	VinNumber	
      IHA	           464057	
      IHA	           936832	
      IHA	           464027	
      A7F	           231114	
      A7F	           897308	
      A7F	           283948	
      A7F	           897262	
      A7F	           897316	
		
[B]I need the result like this[/B]		
VinNumber	Model_Code	Model_Name
    464057	    IHA	            Mohavi
    936832	    IHA	            Mohavi
    464027	    IHA	            Mohavi
    231114	    A7F	            Credenza
    897308	    A7F	            Credenza
    283948	    A7F	            Credenza
    897262	    A7F	            Credenza
    897316	    A7F	            Credenza

#2

Hello, you can try this.

  SELECT T.VinNumber, M.Model_Code, M.Model_Name
    FROM Temp_Model AS M INNER JOIN Txt_Temp AS T ON
    M.Model_Code=T.Model_Code

#3

Thanks for the answer