Selecting data from multiple tables with no common values
915860Feb 7 2012 — edited Feb 7 2012Hi,
Please bear with me as this is my first post and i am relativelly new to SQL.
I am trying to build a query to display data from two three tables grouped by customertype. We have one customer whose data i can recover from one table and another customer whose data needs to be recovered from two tables. There is no common fileld on which to link the customers except on group id.
The group id is unique however.
What i want to do is enter the group id and select data from one of the tables but have it all in one statement. This will be used in production eviroment and therefore i don't want to make two reports
I have tried several different things that do work for one of the customer but when both are in the statenment and the groupid is entered i get errors the the join cant be made.
select 1, 2, 3, 4, 5, 6
from
(
(
select 1, 2, 3, 4, 5, 6
from table1 1, table2 2
where 1.id = 2.id
where id2 = :id
)
union
(
select 1, 2, 3, 4, 5, 6
from table3
where id2 = :id
)
order by 1
;
I also have tried an inline view but also doesnt work.
I hope someone can help.
Kindest regards,
Predrag