日期:2014-05-16  浏览次数:20847 次

为什么mysql select * from (select * from table)会有语法错误
表table
a b c
我的sql语句 select into tmptest from (select * from table)
结果mysql报语法错误,我在网上查似乎sqlserver和oracle都支持这种语法,是不是mysql不支持?
那我应该怎么写,求助...

------解决方案--------------------
SQL code
---mysql不支持者中语法的
---创建表
create table temptest
(id int not null auto_increment,
....
primary key(id))
---插入表
inert into tmptest select * from table;

------解决方案--------------------
create table c as 
select a.a,ifnull(a.b,b.e),ifnull(a.c,b.f)
from a inner join b on a.a=b.d
------解决方案--------------------
create table temptest as select * from 
(select * from test2 as b left join kdpumc0614 as a on (b.cname = a.cname or a.`检验项目别名` like concat('%',b.cname,'%') or a.`正式名称` like concat('%',b.cname,'%') or a.`检验项目英文名称` = b.ename or a.`检验项目英文缩写` = b.testalias) and a.sampletype = b.sampletype
union 
select * from test2 as b right join kdpumc0614 as a on (b.cname = a.cname or a.`检验项目别名` like concat('%',b.cname,'%') or a.`正式名称` like concat('%',b.cname,'%') or a.`检验项目英文名称` = b.ename or a.`检验项目英文缩写` = b.testalias) and a.sampletype = b.sampletype
) t