I am using a database that uses codes for data in some fields. So on insert I use a drop down list for input such as:
<option value="BAL">Bald</option>
<option value="BLK">Black</option>
<option value="BLN">Blond or Strawberry</option>
<option value="BRO">Brown</option>
<option value="GRY">Gray or Partially Gray</option>
For example. However some of the field have hundreds of options. When I query the database I would like to show the full text, not the code. How can I achieve this?
Create another table which stores complete names for these codes with respect to each code like as follow
Table2
__________________________________
|code |name_to_display |
__________________________________
|BAL |Bald |
|BLK |Black |
|BLN |Blond or Strawberry |
|BRO |Brown |
|GRY |Gray or Partially Gray|
__________________________________
let us name it table2 where as the original table is named as table1. Now write a query like Select table1.*,table2.name_to_display from Table1 Left join table2 on table1.code = table2.code and instead of displaying the code you can display the data from name_to_display