Solved

merge data from diferent tables without relations

Posted on 2016-08-24
3
58 Views
Last Modified: 2016-08-25
I hope you can help me with this

I have this two querys
query 1
select field1 from table1 where field1 = 'a'

Open in new window


query 2
select field2 from table where field2 = 'a'

Open in new window


I need to present to my user field1 and field2 as a one table

I was trying to use a union
select field1 from table1 where field1 = 'a'
union all
select field1 from table1 where field1 = 'a'

Open in new window


but mysql show me the result in a single column and I need it in two, for example:
-------------------------------------------------------------
|   field 1                       |       field 2                |
|-----------------------------------------------------------|
|  results of field 1      |  results of field2     |
-------------------------------------------------------------

is it possible to do it like that???
0
Comment
Question by:altariamx2003
[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
3 Comments
 
LVL 15

Accepted Solution

by:
WalkaboutTigger earned 500 total points
ID: 41769606
Select Query1.someCommonField, Query1.field1, Query2.field2
From
(
Select field1, someCommonfield1 as "Common" from table1 where field1 ='a'
) as Query1
inner join
(
Select field2, someCommonField2 as "Common" from table2 where field2='a'
) as Query2
On Query1.Common = Query2.Common
Order By Query1.field1

Open in new window

Realise that the SQL server NEEDS to know how the information from the two fields relate to one another in order to match up the two values.
You, as a human being and familiar with the data, can match the two up.  How are you doing that?  How can you express it in clear language?
Once you can do that, you can fix the query above to meet your needs, even if the relationship is complex.
0
 

Author Comment

by:altariamx2003
ID: 41770953
thx I found the solution by myself, instead of union i use cross join
0
 

Author Closing Comment

by:altariamx2003
ID: 41770955
Thx anyway for your time, but I found the solution bymyself
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
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 …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

624 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