inner join on multiple tables

Techsavy

New member
Local time
Today, 12:48
Joined
May 4, 2008
Messages
6
Hi,


I have a 3 tables

Table 1 -Date Flow1

Table 2 -Date Flow2

Table 3 -Date Flow3


Date is the primary key and I would Like to have

one table with

Date ,flow1, flow2, flow3.

How do I do an inner join at once to get this table.

Thanks,
 
Hi,


I have a 3 tables

Table 1 -Date Flow1

Table 2 -Date Flow2

Table 3 -Date Flow3


Date is the primary key and I would Like to have

one table with

Date ,flow1, flow2, flow3.

How do I do an inner join at once to get this table.

Thanks,

Your question isn't entirely crystal clear because we don't know, for example, whether all three tables have the same set of dates and the same number of rows. Therefore may I suggest, instead of an inner join:


SELECT Table1.*, “Flow1” as FlowType FROM Table1
UNION
SELECT Table2.*, “Flow2” as FlowType FROM Table2
UNION
SELECT Table3.*, “Flow3” as FlowType FROM Table3
 
Query design, add the 3 tables, join table1 date to table2 date, join table2 date to table3 date, select table1 date, flow1, flow2, flow3.
Doesn't this work ?
 
hello Jal,

Thank you for the response.
All the three tables have same set of dates. In the resulting table I would like to have DAte, flow1,flow2,flow3.

Hope this clears the doubt
 
hello Jal,

Thank you for the response.
All the three tables have same set of dates. In the resulting table I would like to have DAte, flow1,flow2,flow3.

Hope this clears the doubt
Well,in that case, I think Mearle's response is what you need. Have you tried it?
 
I don't know you're level of experience, so in case you need more help, here is a possible solution:


SELECT T1.Date, T1.Flow as Flow1, T2.Flow as Flow2, T3.Flow as Flow3
FROM ((Table1 as T1
INNER JOIN Table2 as T2 ON T2.Date = T1.Date)
INNER JOIN Table3 as T3 ON T3.Date = T2.Date)
 

Users who are viewing this thread

Back
Top Bottom