1

Importing from one table to another.. this errors.

INSERT INTO wp_users (DEFAULT, user_login, user_pass, user_nicename, user_email, user_url, user_registered, user_status, display_name)
SELECT ID, username, password, LOWER(username), email, company_url, date_added, '0', username
FROM user
WHERE ID BETWEEN 5000 to 10000;

I just don't want the ID inserted as it's auto-incremented in wp_users so I'm using "DEFAULT".

Error: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT, user_login, user_pass, user_nicename, user_email, user_url, user_regist' at line 1

1 Answer 1

1

DEFAULT, user are reserved words in MySQL, escape them. Also the predicate BETWEEN should be BETWEEN ... AND ... not BETWEEN ... TO ...:

INSERT INTO wp_users (`DEFAULT`, user_login, user_pass, user_nicename, user_email, user_url, user_registered, user_status, display_name)
SELECT ID, username, password, LOWER(username), email, company_url, date_added, '0', username
FROM `user`
WHERE ID BETWEEN 5000 AND 10000;
Sign up to request clarification or add additional context in comments.

13 Comments

Thanks, but still errors :( #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'to 10000' at line 4
@Dave user also a reserved word, escape it.
@Dave Sorry again, it is WHERE ID BETWEEN 5000 AND 10000; not WHERE ID BETWEEN 5000 to 10000;
No problem! Now a new error haha #1054 - Unknown column 'DEFAULT' in 'field list'
@Dave - I am working on that, just give me some minutes please. Sorry.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.