[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

SQL within Select

Posted on 2008-02-04
2
Medium Priority
?
2,040 Views
Last Modified: 2012-06-21
A basic question. I am trying to get the Plan Name to be included in the results returned. I used ot remember how to do this. Thanks for any help.


SELECT Employee.[SSO], CbsiHistory.[PlanID]
FROM Employee, CbsiHistory
WHERE
CbsiHistory.[PlanID] =
(select [ID], [Name] from [Plan] where [ID] = CbsiHistory.[PlanID])
and Employee.[ID] = CbsiHistory.[EmployeeID]
0
Comment
Question by:scorpion53061
2 Comments
 
LVL 23

Expert Comment

by:debuggerau
ID: 20820561
SELECT Employee.[SSO], CbsiHistory.[PlanID], CbsiHistory.[Plan Name]
FROM Employee, CbsiHistory
WHERE
CbsiHistory.[PlanID] =
(select [ID], [Name] from [Plan] where [ID] = CbsiHistory.[PlanID])
and Employee.[ID] = CbsiHistory.[EmployeeID]

Is this what your after?
0
 
LVL 39

Accepted Solution

by:
appari earned 2000 total points
ID: 20820582
SELECT Employee.[SSO], CbsiHistory.[PlanID], [ID], [Name]
FROM Employee, CbsiHistory, [Plan]
WHERE
[Plan].[ID] = CbsiHistory.[PlanID]
and Employee.[ID] = CbsiHistory.[EmployeeID]

or

SELECT Employee.[SSO], CbsiHistory.[PlanID],
(select  [Name] from [Plan] where [Plan].[ID] = CbsiHistory.[PlanID])
FROM Employee, CbsiHistory
WHERE
Employee.[ID] = CbsiHistory.[EmployeeID]
 
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Suggested Courses

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question