MySQL INSERT SELECT 不插入 [英] MySQL INSERT SELECT not Inserting

查看:46
本文介绍了MySQL INSERT SELECT 不插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试取消一个看起来像这样的插入选择:

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'

但是,当我在引用1"的 phpMyAdmin 中运行它时出现问题:

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

我尝试了 SELECT、INSERT 等的多种不同组合,但我发现了问题所在.我也看过这里和其他论坛上的任何不同帖子,但大多数建议我使用的语法!

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!

我尝试在这里设置 SQL Fiddle:http://sqlfiddle.com/#!9/9f460

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 :)

推荐答案

您缺少第三列:

INSERT INTO users_extension_usage(userid, extensionid, complete) 
    SELECT '3', extensions.id, '1' as complete
    FROM extensions
    WHERE extensions.folder = 'definitions';

'1' 属于 SELECT 语句,而不是在 WHERE 之后.

The '1' belongs in the SELECT statement, not after the WHERE.

这篇关于MySQL INSERT SELECT 不插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆