December 1, 2009 at 1:44 pm
I have a table in which the last colum defines the type of table for eg.
I have 6 values ,Boolean attribute,date attribute,interestattribute. and so on.
Now i need to join these tables to the main table base on the value in the last column.
so which says case if 1 then join 1st table , 2 then 2nd table and so.on.
Is it possible for a conditional Join to work...? i.e case if 1 then join 1st table..any workaround on this technique?
December 1, 2009 at 1:49 pm
Obviously a host of ways, but the simplest method, and easiest to debug, would be to create 6 select statements, with WHERE clauses - one for each type, and Union them all together. In that way, each statement will access one other table only, and the Where clause will indicate which table is to be joined.
As said, many ways, but without knowing the size of the tables, etc, I prefer to look at the easiest method.
December 1, 2009 at 1:55 pm
Individual joins and union statements is how I'd initially go too. Easier and more performant than case statements in join clauses.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
December 1, 2009 at 1:56 pm
Indeed I need to be careful since the table structure i am talking holds up account attributes and goes into a large value..Hence currently skipped that option. Any other way?...maybe I am still looking into it.
December 2, 2009 at 1:06 am
Try using Left Outer Join with all tables according their fields with Distinct Clause...
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply