CTE的语法无效

时间:2012-11-08 03:53:35

标签: sql-server tsql

世界上可能出错的地方,语法看起来不错:

With photos(PhotoID, MemberID) as
(
    select  photoID,
            memberID
    from MemberPhotos
)
select PhotoID, MemberID from photos

1 个答案:

答案 0 :(得分:3)

如果CTE来自其他查询,则应在semi-colon关键字之前添加WITH

;With photos(PhotoID, MemberID) as
(
    select  photoID,
            memberID
    from MemberPhotos
)
select PhotoID, MemberID from photos