Posted on 2007-04-03
Last Modified: 2012-06-21
Hi Experts,

SELECT Name From TableName WHERE id=1

SELECT FirstName From TableFirstName  WHERE id=1

I want a result in 1 resultset like this:
Name | FirstName

Thanks in advance for your help.
Question by:noulouk
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 18844576
one way is

SELECT (SELECT Name From TableName WHERE id=1) Name ,
 (SELECT FirstName From TableFirstName  WHERE id=1) FirstName

Otherway is join the two tables, for which we need information on how these two tables are related


Author Comment

ID: 18844647
OK, but I have several columns to select in my tables like this:
SELECT Name, Name2, Name3 From TableName WHERE id=1

SELECT FirstName,FirstName2,... From TableFirstName  WHERE id=1

LVL 75

Accepted Solution

Aneesh Retnakaran earned 480 total points
ID: 18844665
Select f.Name, f.Name1, f.name2, f.Name3
          S.FirstName, s.FirstName2
FROM TableName f
INNER JOIN TableFirstName S
ON f.ID = S.ID
WHERE s.ID  = 1
LVL 42

Assisted Solution

dqmq earned 20 total points
ID: 18845320
It would be helpful if you show the table structures along with the desired output.  That way we don't have to guess.

Author Comment

ID: 18846217
I 'm agree dqmq.
I will  ask a new question.

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

690 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