On Mon, Dec 29, 2008 at 10:17 AM, Keith Spiller <larentium@xxxxxxxxxxxx> wrote: > 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. The idea is right, the format of the query isn't. I use the case statement for this but it's up to you - work out the right format for IF from the mysql manual. (case when o.product_type='course' then o.product_id else null end case) as field4 -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php