Code:
UPDATE `j25_virtuemart_userinfos` SET `virtuemart_user_id`='[user_id]',`company`=IFNULL('[company]',`company`),`title`=IFNULL('[title]',`title`),`last_name`='[lastname]',`first_name`='[firstname]',`middle_name`=IFNULL('[middlename]',`middle_name`),`phone_1`=IFNULL('[phone]',`phone_1`),`fax`=IFNULL('[fax]',`fax`),`address_1`=IFNULL('[location]',`address_1`),`address_2`=IFNULL('[address]',`address_2`),`city`=IFNULL('[city]',`city`),`virtuemart_state_id`=IFNULL('[state]',`virtuemart_state_id`),`virtuemart_country_id`=IFNULL('[cb_select_country]',`virtuemart_country_id`),`zip`=IFNULL('[zipcode]',`zip`) WHERE `virtuemart_user_id`='[user_id]';
If any of these optional fields are NULL then this merely puts the value [cb_field] into the table, rather than preserving the existing value, which is probably NULL already. Omitting the quotes round the [cb_filed] generates a syntax error/ Is there another way to do this?