日期:2014-05-19  浏览次数:20431 次

帮我看看这条SQL语句是什么意思?内容看正文
SELECT   CASE   WHEN   EXISTS   (SELECT   *   FROM   dbo.tbRevisionSupersedesUpdate   AS   S   WHERE   S.SupersededUpdateID=Up.UpdateID)   THEN   CAST   (1   AS   BIT)   ELSE   CAST(0   AS   BIT)   END   AS   IsSuperseded)

------解决方案--------------------
SELECT * FROM dbo.tbRevisionSupersedesUpdate AS S WHERE S.SupersededUpdateID=Up.UpdateID


---如果这个语句查询有记录就返回1,否则返回0
------解决方案--------------------
SELECT CASE WHEN
EXISTS (SELECT * FROM dbo.tbRevisionSupersedesUpdate AS S WHERE S.SupersededUpdateID=Up.UpdateID)
THEN CAST (1 AS BIT)
ELSE CAST(0 AS BIT) END
AS IsSuperseded--去掉这个)

exists为判断真假


------解决方案--------------------
end是case语句的结束,AS IsSuperseded 列别名