Re: [PHP-DB] Re: New Table Creation with PHP Variables

[email protected] ("Jack van Zanen")
Newsgroups php.db
Message-ID <[email protected]>
That looks like it should work, just execute the select query and see what
is the output


Jack

2008/12/29 Keith Spiller <[email protected]>

> Another option that would work if I can figure out the correct syntax is to
> just NULL certain values if a given condition exists.  If
> product_type='course' then just use the o.product_id value for field4.  If
> product_type != 'course' then use NULL for field4.
>
> CREATE TABLE $table[name]
> SELECT field1, field2, field3,
> IF(o.product_type='course', o.product_id, NULL) AS field4,
> field5, field6, field7
> FROM table1 as a, table2 as o;
>
> Is this right?  Thank you for your help.
>
> Keith
>
>
> ----- Original Message ----- From: "Keith Spiller" <[email protected]
> >
> To: "php_db" <[email protected]>
> Sent: Sunday, December 28, 2008 5:39 PM
> Subject: New Table Creation with PHP Variables
>
>
>
> 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
>>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
J.A. van Zanen
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.