# Select field dependent upon other field

**URL:** <https://forum.kirupa.com/t/select-field-dependent-upon-other-field/277772>\
**Category:** programming\
**Created:** [December 17, 2008, 2:27am UTC](https://forum.kirupa.com/t/select-field-dependent-upon-other-field/277772 "2008-12-17T02:27:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Icy\_Penguin](https://avatars.discourse-cdn.com/v4/letter/i/f6c823/32.png) [@Icy\_Penguin](https://forum.kirupa.com/u/Icy_Penguin)\
**Post date:** [December 17, 2008, 2:27am UTC](https://forum.kirupa.com/t/select-field-dependent-upon-other-field/277772/1 "2008-12-17T02:27:54Z")

</div>

Sorry I couldn’t word this better in the title.

What I have is a table with a column ‘type’ - my records in that table all have one of four possible values for ‘type’ - e.g., type1, type2, type3, or type4. Also, each record has four additional columns: type1, type2, type3, or type4.

Based on what that row’s ‘type’ value is, I want to select the column whose name matches that value.

So, if record id # 314 has a ‘type’ value of ‘type3’, I want to select that record’s value from it’s ‘type3’ column.

I tried something like this, but it doesn’t work of course:

```auto

SELECT 'table_name.type' FROM table_name WHERE id='$my_id'

```

Thanks 🙂
