Skip to content

Instantly share code, notes, and snippets.

@remcotolsma
Last active August 29, 2015 14:17
Show Gist options
  • Save remcotolsma/202cdcedc3f6e2b3c32d to your computer and use it in GitHub Desktop.
Save remcotolsma/202cdcedc3f6e2b3c32d to your computer and use it in GitHub Desktop.
Select Easy Digital Downloads license users and post authors.
SELECT
post.ID,
post.post_author,
post.post_title,
post.post_date,
post.post_type,
meta.meta_value AS edd_sl_user_id
FROM
wp_2_posts AS post
LEFT JOIN
wp_2_postmeta AS meta
ON post.ID = meta.post_id AND meta.meta_key = '_edd_sl_user_id'
WHERE
post.post_type = 'edd_license'
AND
post.post_date < '2014-12-10 15:00:00'
AND
post.post_author NOT IN ( 1, 2 )
AND
post.post_author != meta.meta_value
ORDER BY
post_date
;
UPDATE
wp_2_posts AS post
LEFT JOIN
wp_2_postmeta AS meta
ON post.ID = meta.post_id AND meta.meta_key = '_edd_sl_user_id'
SET
meta.meta_value = post.post_author
WHERE
post.post_type = 'edd_license'
AND
post.post_date < '2014-12-10 15:00:00'
AND
post.post_author NOT IN ( 1, 2 )
AND
post.post_author != meta.meta_value
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment