// Create a function to "explode" the single name field
CREATE FUNCTION SPLIT_STRING(str VARCHAR(255), delim VARCHAR(12), pos INT)
RETURNS VARCHAR(255)
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(str, delim, pos),
LENGTH(SUBSTRING_INDEX(str, delim, pos-1)) + 1),
delim, '');
// Process the first name
INSERT INTO `iiid_comprofiler` (`firstname`)
SELECT `iiid_users` SPLIT_STRING(`name`, ',', 1);
// Process the middle name
INSERT INTO `iiid_comprofiler` (`middlename`)
SELECT `iiid_users` SPLIT_STRING(`name`, ',', 2);
// Process the last name
INSERT INTO `iiid_comprofiler` (`lastname`)
SELECT `iiid_users` SPLIT_STRING(`name`, ',', 3);
//Process other profile info
INSERT INTO `iiid_comprofiler` (`cb_address`, `cb_address2`, `city`, `state`, `zip`, `phone`)
SELECT `iiid_user_profiles` (`address1`, `address2`, `city`, `state`, `zip_code`, `phone`);
Please Log in to join the conversation.
UPDATE cb
SET cb.`firstname` = SPLIT_STRING( j.`name`, ',', 1 ), cb.`middlename` = SPLIT_STRING( j.`name`, ',', 2 ), cb.`lastname` = SPLIT_STRING( j.`name`, ',', 3 )
FROM `iiid_comprofiler` AS cb
INNER JOIN `iiid_users` AS j
ON j.`id` = cb.`id`
UPDATE cb
SET cb.`cb_address` = j.`profile_value`
FROM `iiid_comprofiler` AS cb
INNER JOIN `iiid_user_profiles` AS j
ON j.`user_id` = cb.`id`
WHERE j.`profile_key` = 'address1'
Please Log in to join the conversation.