Solved

Merge SELECT

Posted on 2007-04-03
5
192 Views
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.
0
Comment
Question by:noulouk
  • 2
  • 2
5 Comments
 
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


0
 
LVL 9

Author Comment

by:noulouk
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

Sorry.
0
 
LVL 75

Accepted Solution

by:
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
0
 
LVL 42

Assisted Solution

by:dqmq
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.
0
 
LVL 9

Author Comment

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

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Suggested Solutions

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
This video discusses moving either the default database or any database to a new volume.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now