This question is strictly related to the mysql query not the php code.
I need to either create a new table from the old one or add columns.
The thing is don't know how to do it.

let me simplify things up:

I need a query to retrieve values from the table PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS to a new one or add columns.
the new table should look like

ID     Hair             Eyes
      Blond          Green
      Brunette      Hazel

The php code is not what I want I need the query, to do exactly that.
Then I will use it in my php code, but what that is not what I am asking at this time. Just the query to do that.

Thanks,

Rick Fitzgerald


John Meyer wrote:
It would be better to post this sort of question at [EMAIL PROTECTED]
axis wrote:
Hi,

I want to create a new column or table from queries of the values of columns I( already have.

My table is :

PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS
products_id     products_extra_fields_id     products_extra_fields_value
1 1 Blond 1 2 Green 1 3 1.75 1 4 24 2 1 Brunette 2 2 Hazel 2 3 1.56 2 4 28


with this Select query >>>

function get_extra($extra_array = '') {
   if (!is_array($extra_array)) $extra_array = array();

$extra_query = db_query("select products_extra_fields_value from " . TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS . " where products_extra_fields_id = '1'");
   while ($extra = db_fetch_array($extra_query)) {
$extra_array[] = array('id' => $extra['products_extra_fields_id'], 'text' => $extra['products_extra_fields_value']);
   }

   return $extra_array;
 }

This function uses the query: select products_extra_fields_value from PRODUCTS_EXTRA_FIELDS where products_extra_fields_id = 1;

and returns Rubia and Morocha which is fine, now I need to

either create a new column or table in order to be able to have those values in their own column

my knowledge of mysql is limited so please give me suggestions as what to use in order to create a function to retrieve values and add them automatically to my table or columns

The table or columns have to be something like:

ID     Hair             Eyes
       Blond          Green
       Brunette      Hazel

so I can call them later by selecting from a column in a table like TABLE_PRODUCTS_EXTRA_FIELDS_TO_PRODUCTS_EXTRA_FIELDS_VALUE

pef2pev.hair, pef2pev.eyes ... and so on

here is my current switch

for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
   switch ($column_list[$i]) {
     case 'PRODUCT_LIST_MODEL':
       $select_column_list .= 'p.products_model, ';
       break;
     case 'PRODUCT_LIST_MANUFACTURER':
       $select_column_list .= 'm.manufacturers_name, ';
       break;
       // aDD eXTRA FIELdS
     case 'PRODUCT_LIST_HAIR':
                $select_column_list .= 'pef2pev.hair, ';
         break;

and so on ...

    break;
   }
 }

Thanks


Rick Fitzgerald







--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to