You will need dynamic SQL to achieve that.
What database are you using ? what version ?
In Sql Server, this would be one way to do it:
<pre>DECLARE @selectStmt nvarchar(4000),
SELECT @field =
WHEN fld_type1 = ‘A’ THEN ‘VAL_ALPHA1′
WHEN fld_type1 = ‘D’ THEN ‘VAL_DATE1′
SET @selectStmt = ‘SELECT ‘+@field+’ FROM table2 WHERE id = 8′
Beware that dynamic SQL pose some security issues.
Have a look at the following article to read more about Dynamic SQL:
<a href=”http://www.sommarskog.se/dynamic_sql.html”>The Curse and Blessings of Dynamic SQL</a>