January 25, 2007 at 3:35 am
Can any one answer the following
i have two tables like TabA and TabB
In TabA contains column like 'code' it holds char. ex : 'A', 'B' and etc
In TabB having data for the corresponding code with separate column ex: DataA, DataB,.....
here i have to query the data from TabB by corresponding code..
ex: select tabB.Code, tabB.data<code> from ...
is there any way to evaluate column name while runtime
Thanks
Kalai
Kalai
January 25, 2007 at 3:51 am
Yes, with Case, i.e. (the query of course depends on how to stick taba and tabb together):
SELECT
TabA....
CASE
WHEN TabA.code='A' THEN TabB.DataA
WHEN TabA.code='B' THEN TabB.DataB
...
ELSE 'x'
END AS data
FROM
TabA
LEFT JOIN TabB ON TabB.whatever = TabA.whatever
January 25, 2007 at 4:09 am
Thank u Gross, it works well.
Thanks
Kalai
Kalai
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply