I just added users into my WordPress installation from another CMS, and now I need for each user id in wp_users
insert new value with its id into wp_usermeta
. Is there any ideas for this in SQL?
Leave a Reply
You must be logged in to post a comment.
You can use a SELECT statement as a source of values for an INSERT, like this:
The IGNORE keyword tells MySQL to insert the rows that it can, and if any rows we try to insert are “duplicate” rows (throw an exception), then just let those rows not be inserted, and ignore the errors that would otherwise be thrown.
Try this :
Making use of single-quoted string literals, you can use the
INSERT INTO ... SELECT
syntax to simultaneously select all user ids fromwp_users
and insert string values intowp_usermeta
: