Reputation: 437
I am trying tor un an insert select that looks like this:
INSERT INTO users_extension_usage (userid, extensionid, complete)
SELECT '3', extensions.id FROM extensions WHERE extensions.folder='definitions', '1'
however it has a problem when I run it in phpMyAdmin that refers to the '1':
#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 ' '1'' at line 2
I have tried many different combinations of SELECT, INSERT etc but I cat see the problem. I have looked at any different posts on here and other forums too but alas most suggest the syntax I am using!
I have tried to set up an SQL Fiddle here: http://sqlfiddle.com/#!9/9f460
Any suggestions for how this might work will be gratefully accepted :)
Upvotes: 3
Views: 173
Reputation: 1269493
You are missing the third column:
INSERT INTO users_extension_usage(userid, extensionid, complete)
SELECT '3', extensions.id, '1' as complete
FROM extensions
WHERE extensions.folder = 'definitions';
The '1'
belongs in the SELECT
statement, not after the WHERE
.
Upvotes: 7