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

MySQL中有类似MSSQL中的with关键字么
MS-SQL 2005以后,声明临时表出现With的用法。比如:
with tb as(
select orderid,sum(Qty) as 数量 from orderdetails group by orderid 
)
select *
from tb tb1
join tb tb2 on tb1.orderid=tb2.orderid
......
......
像这种临时表tb我需要多次使用,用with声明比较方便。

在MySQL中有类似关键字么?或者MySQL的解决方案是什么?
初来乍到,请教大家。

------解决方案--------------------
没有。
------解决方案--------------------
没有。

你可以通过子查询,或者临时表来解决。
------解决方案--------------------
可以这样使用零时表。比如t就是一个零时表

mysql> select * from (select * from user) as t where t.userName="zhanghong";
------解决方案--------------------
暂时还没这个功能