SQL: Querying column name using value of other field
<p>I have the following 3 fields in the same table:</p>

<pre><code>cell   |    home    |    primary 
----------------------------------------------
 111        2222          cell
 456565     4654564       home
</code></pre>

<p>I would like to reach the value of either <code>cell</code> or <code>home</code> based on the value of the <code>primary</code> field.</p>

<p>I tried the following, which obviously does not work... but can't figure out how to convert the value of <code>primary</code> to be understood as a column name:</p>

<pre><code>SELECT 
    (SELECT primary FROM tblstudents WHERE studentid = 39358) 
FROM
    tblstudents WHERE studentid = 39358
</code></pre>

<p>Thanks</p>