Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select Query

Author  Topic 

teamjai
Yak Posting Veteran

52 Posts

Posted - 2013-11-07 : 04:31:55
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

52326 Posts

Posted - 2013-11-07 : 04:38:01
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
   

- Advertisement -