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
Solved

Need sql query to retrieve result

Posted on 2011-03-24
6
474 Views
Last Modified: 2012-05-11
these are my sql tables. how can i get the result here..
my table desription..


Table 1
...........
Col1 pk
Col2

Table 2
..........
Col3 pk
Col4

Table3
...........
col3 fk
col1 fk
col5

Now i want data like this

result is
.......
col2
col4

Here col2 and col4 as a single column(concatination).

Here my sql statement is failed to retrieve result..

Can anyone know sql query to get result..
0
Comment
Question by:lucky20
6 Comments
 
LVL 24

Expert Comment

by:jimyX
ID: 35210742
Select Col2 from Table1 union select Col4 from Table2 union select col5 from Table3
0
 
LVL 24

Expert Comment

by:jimyX
ID: 35210753
To allow duplicate values use union all:
Select Col2 from Table1 union all select Col4 from Table2 union all select col5 from Table3
0
 
LVL 24

Accepted Solution

by:
jimyX earned 500 total points
ID: 35210773
Not sure i got your point there but if you just want Col2 and Col4 then:

Select Col2 from Table1 union all select Col4 from Table2
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 5

Expert Comment

by:bitref
ID: 35210779
Select t1.col2, t2.col4
From t1
	Inner Join t3 on t1.col1 = t3.col1
	Inner Join t2 on t3.col3 = t2.col3

Open in new window

0
 
LVL 32

Expert Comment

by:ewangoya
ID: 35210972

Select Col2
from Table1
union all
select Col4
from Table1
inner join Table2 on Table2.Col3=Table1.Col1
0
 
LVL 1

Author Comment

by:lucky20
ID: 35211552
thanks to every one..
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

861 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