select * from (select a.value,a.id,b.value from a,b where a.value=b.value ) k;
create temporary table k select a.value,a.id,b.value from a,b where a.value=b.value不过临时表只能生存在当前连接中 版主大人救命啊,我我只是想将查询到的结果作为一张临时表k存放起来而已的,很简单的
create table temp_table as select * from table;
创建临时表是用create temporary table tablename,然后把数据插入。 在phpmyadmin运行可以看到结果create temporary table k( `a` varchar(20) NOT NULL, `aid` int(11) NOT NULL, `b` varchar(20) NOT NULL );insert into k(a,aid,b) select a.value,a.id,b.value from a,b where a.value=b.value;select * from k;
版主写的那句需要改一改。create temporary table k select a.value as aval,a.id as aid,b.value as bval from a,b where a.value=b.value; select * from k; 否则会有两个value,导致出错。#1060 - Duplicate column name 'value'
with k as (select a.value,a.id,b.value as value1 from a,b where a.value=b.value)select * from k 或者是 select * from (select a.value,a.id,b.value as value1 from a,b where a.value=b.value) k 需要注意的是select a.value,a.id,b.value这里不能有重复的字段
版主大人救命啊,我我只是想将查询到的结果作为一张临时表k存放起来而已的,很简单的
在phpmyadmin运行可以看到结果create temporary table k(
`a` varchar(20) NOT NULL,
`aid` int(11) NOT NULL,
`b` varchar(20) NOT NULL
);insert into k(a,aid,b) select a.value,a.id,b.value from a,b where a.value=b.value;select * from k;
select * from k;
否则会有两个value,导致出错。#1060 - Duplicate column name 'value'
或者是
select * from (select a.value,a.id,b.value as value1 from a,b where a.value=b.value) k
需要注意的是select a.value,a.id,b.value这里不能有重复的字段