Mysql 为什么这个工会不都能运作?

Mysql 为什么这个工会不都能运作?,mysql,Mysql,我创建一个查询,将一个表的数据传递给另一个表,但返回一个错误: 塞姆博罗(代币)因斯佩拉多。(位置150的“全部联合”附近) 我的问题是: insert into vencimientos_arba(impuestoId, impuesto, vencimiento) select id, concepto, CONCAT('2017-', anticipo1) AS concatenar from ingresos_brutos UNION ALL select id, concepto, C

我创建一个查询,将一个表的数据传递给另一个表,但返回一个错误:

塞姆博罗(代币)因斯佩拉多。(位置150的“全部联合”附近)

我的问题是:

insert into vencimientos_arba(impuestoId, impuesto, vencimiento)
select id, concepto, CONCAT('2017-', anticipo1) AS concatenar from ingresos_brutos
UNION ALL
select id, concepto, CONCAT('2017-', anticipo2) AS concatenar from ingresos_brutos
UNION ALL
select id, concepto, CONCAT('2017-', anticipo3) AS concatenar from ingresos_brutos
UNION ALL
select id, concepto, CONCAT('2017-', anticipo4) AS concatenar from ingresos_brutos
UNION ALL
select id, concepto, CONCAT('2017-', anticipo5) AS concatenar from ingresos_brutos
UNION ALL
select id, concepto, CONCAT('2017-', anticipo6) AS concatenar from ingresos_brutos
UNION ALL
select id, concepto, CONCAT('2017-', anticipo7) AS concatenar from ingresos_brutos
UNION ALL
select id, concepto, CONCAT('2017-', anticipo8) AS concatenar from ingresos_brutos
UNION ALL
select id, concepto, CONCAT('2017-', anticipo9) AS concatenar from ingresos_brutos
UNION ALL
select id, concepto, CONCAT('2017-', anticipo10) AS concatenar from ingresos_brutos
UNION ALL
select id, concepto, CONCAT('2017-', anticipo11) AS concatenar from ingresos_brutos
UNION ALL
select id, concepto, anticipo12 AS concatenar from ingresos_brutos
UNION ALL
select id, concepto, anual AS concatenar from ingresos_brutos
ORDER BY id ASC

与其他一些数据库引擎不同,在MySQL中,我们需要使用
value
关键字和
INSERT-INTO
SELECT

INSERT INTO table (columns) VALUES
SELECT columns FROM table
 UNION ALL 
SELECT columns FROM table
...

这就是我们看到问题中显示的“意外令牌”错误的原因。

与其他一些数据库引擎不同,在MySQL中,我们需要将
关键字与
插入
选择

INSERT INTO table (columns) VALUES
SELECT columns FROM table
 UNION ALL 
SELECT columns FROM table
...

这就是我们在问题中看到“意外标记”错误的原因。

第3行“选择id、概念、CONCAT('2017-',anticipo1)作为Ingreos_brut的concatenar”附近的语法有问题吗?(意外标记已消失)这是确切的错误吗?我看到
CONCAT(danticipo12)
与查询中的其他列名不匹配。这可能是错误的根源吗?或者您在
SELECT
语句中使用
id
而不是
imputestoid
?如果它返回的是确切的错误,并且我已经将“anticipo12”改为“anticipo12”,但它不会改变任何东西
id
而不是
SELECT
列中的
imputestoid
,对不起,看来我错了。刚刚做了一些测试并插入到。。。SELECT
是MySQL的正确语法(不需要
值),至少在MySQL 5.6中是这样。我会更新答案……令人惊讶的是没有人发现这一点。第3行的“选择id,concepto,CONCAT('2017-',anticipo1)作为Ingreos_brut的concatenar”附近的语法有问题?(意外标记已消失)这是确切的错误吗?我看到
CONCAT(danticipo12)
与查询中的其他列名不匹配。这可能是错误的根源吗?或者您在
SELECT
语句中使用
id
而不是
imputestoid
?如果它返回的是确切的错误,并且我已经将“anticipo12”改为“anticipo12”,但它不会改变任何东西
id
而不是
SELECT
列中的
imputestoid
,对不起,看来我错了。刚刚做了一些测试并插入到。。。SELECT
是MySQL的正确语法(不需要
值),至少在MySQL 5.6中是这样。我会更新答案…很惊讶没人发现。