Solved

Merge SELECT

Posted on 2007-04-03
5
231 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
[X]
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
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

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Truncate vs Delete 63 108
CREATE DATABASE ENCRYPTION KEY 1 80
Loops and updating in SQL Query 9 66
Ideas on migrating very large  system from SQL 2005 to SQL 2014 3 32
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…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 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