Skip to content

Instantly share code, notes, and snippets.

@cezarpopa
Created May 3, 2016 18:18
Show Gist options
  • Save cezarpopa/d8dac233ff62d4397569418ddfbc5ef7 to your computer and use it in GitHub Desktop.
Save cezarpopa/d8dac233ff62d4397569418ddfbc5ef7 to your computer and use it in GitHub Desktop.
Woocommerce to MailPoet userinfo import
UPDATE (
SELECT
u.ID as ID,
u.user_email as email,
max( CASE WHEN um.meta_key = 'billing_first_name' and u.ID = um.user_id THEN um.meta_value END ) as billing_first_name,
max( CASE WHEN um.meta_key = 'billing_last_name' and u.ID = um.user_id THEN um.meta_value END ) as billing_last_name,
max( CASE WHEN um.meta_key = 'billing_address_1' and u.ID = um.user_id THEN um.meta_value END ) as billing_address_1
FROM awp_users as u
INNER JOIN
awp_usermeta as um on u.id = um.user_id
GROUP BY u.ID ) t1 inner join awp_wysija_user awu on t1.ID=awu.wpuser_id
set awu.firstname = COALESCE(t1.billing_first_name, ''),awu.lastname = COALESCE(t1.billing_last_name,''),awu.cf_2 = COALESCE(t1.billing_address_1,'');
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment