您的位置:首页 > 数据库

SQL中With关键字的简单用法

2011-02-25 03:18 239 查看
代码如下:

select * from dbo.HRReOrPuType

/* with 的写法避免了产生临时表的IO,更多建议请参考:http://wudataoge.blog.163.com/blog/static/80073886200961652022389/ */
with t_rePuType1 as
(
select Id from HRReOrPuType where typeName like '出勤奖%'
)/* 后面可以接N个,但with结束后,必须使用with定义的这些变量 ,
t_rePuType2 as
(

) */
select * from dbo.HRUserReAndPu where hRReOrPuTypeId in (select * from t_rePuType1)


谢谢您的浏览!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: