SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select Query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

teamjai
Starting Member

India
44 Posts

Posted - 11/07/2013 :  04:31:55  Show Profile  Reply with Quote
i have Two table

1) Country

ID Name
----- ---------
123 UK
456 US
789 SF

2)Document

Did DName Description CountryID
------- -------- ------------ -----------
111 Test Sample 123
222 TTest SSample 789

i need to retrive the value from Document table.
Example:

Select CountryID from Document where Did = 111

The above query return Country id , but i need to return Country Name

Excepted O/p --> UK

Please help

Thanks




visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 11/07/2013 :  04:38:01  Show Profile  Reply with Quote
just a simple join

SELECT c.Name
FROM Country c
INNER JOIN Document d
ON d.CountryID = c.ID
WHERE Did = 111


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000