New Table Creation with PHP Variables
| From: | Keith Spiller | Date: | Mon, 29 Dec 2008 00:39:08 +0000 |
| Subject: | New Table Creation with PHP Variables | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-45838@lists.php.net to get a copy of this message | ||
Hi,
I'm trying to join multiple tables to then create a new table from the query. I've figured out that part, but some of the fields need to be evaluated and then compared to a php array to derive their data. In this example I am trying to populate the field4 column (from the $product_name array) after evaluating the product_type value on each row.
CREATE TABLE $table[name]
SELECT field1, field2, field3,
IF(o.product_type='course', $product_name[$product_id], NULL) AS field4, field5, field6, field7
FROM table1 as a, table2 as o;
Is this possible? Is there another way to accomplish this task? Thanks for your help.
Keith