我有以下疑问
insert into T1 (code, code2, type, is_default, m_order, m_type, title, created_by)
select t.*
from (select a.code from (select code from T2 where type = 171 and value = 'ABC') a,
select b.code from (select code from T2 where type = 170 and value = 'D') b,
'Value', 1, 1, 1, 'Type', 'System'
UNION ALL
select c.code from (select code from T2 where type = 171 and value = 'DEF') c,
select d.code from (select code from T2 where type = 170 and value = 'D') d,
'Value', 1, 2, 2, 'Loc', 'System'
) t
where not exists (select ... (with joins));
错误:
SQL Error [1064] [42000]: 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 'select b.code from (select code from T2 where type = 170 an' at line 4
我不确定为什么会有任何错误.我只是根据条件插入从其他表获取的值.我遵循了this answer,它适用于从单个表进行插入/ Select .但当我试图从其他表中获取价值时,它不起作用.
我做错了什么?