zoukankan      html  css  js  c++  java
  • sql server with as只能查询一次

    WITH
         Emp AS
            (SELECT acc.*
            FROM GXSpreadDB.dbo.gxs_account acc
            LEFT JOIN RYAccountsDB.dbo.AccountsInfo Account
                ON acc.userid=Account.userid 
            WHERE parentuserid=7123 
                   AND Account.AgentID=0
            UNION ALL
            SELECT d.* FROM Emp ,GXSpreadDB.dbo.gxs_account d 
            WHERE d.parentuserid =Emp.userid ),
        DaiLi_RelationalTree AS
        (
            select * from GXSpreadDB.dbo.gxs_account where gameid=208356
        )
        --select * from DaiLi_RelationalTree
        select * from Emp,DaiLi_RelationalTree

    以上代码是没问题的。

    这个代码就会报对象不存在。可能要插入到临时表才能重复查询吧

      WITH
         Emp AS
            (SELECT acc.*
            FROM GXSpreadDB.dbo.gxs_account acc
            LEFT JOIN RYAccountsDB.dbo.AccountsInfo Account
                ON acc.userid=Account.userid 
            WHERE parentuserid=7123 
                   AND Account.AgentID=0
            UNION ALL
            SELECT d.* FROM Emp ,GXSpreadDB.dbo.gxs_account d 
            WHERE d.parentuserid =Emp.userid ),
        DaiLi_RelationalTree AS
        (
            select * from GXSpreadDB.dbo.gxs_account where gameid=208356
        )
        select * from DaiLi_RelationalTree
        select * from Emp,DaiLi_RelationalTree
  • 相关阅读:
    爬虫
    Django
    python多线程
    python基础
    深度学习_1_Tensorflow_1
    人工智能_5_决策树_随机森林
    人工智能_4_k近邻_贝叶斯_模型评估
    人工智能_3_机器学习_概述
    Python re 模块
    Python函数式编程
  • 原文地址:https://www.cnblogs.com/codeDevotee/p/11349978.html
Copyright © 2011-2022 走看看