MSSQL的多层嵌套查询
生活随笔
收集整理的這篇文章主要介紹了
MSSQL的多层嵌套查询
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
今天在聊天系統中需要系統執行一個多層嵌套查詢。
一開始語句如下總出現錯誤:原來是在]='123') 后我多加了一個 as tb1
?
改為如下后,正確運行。
select * from ( select top(10)? * from ( select top(100)? * from (select? [chatcontent].[senderid],[chatcontent].[id] ,[chatcontent].[toid] ,[chatcontent].[sendtime] ,[chatcontent].[sendcontent]? from [chatcontent] where [chatcontent].[id] not in (select [messageid] from [messagereaded] where [messagereaded].[toid]='123') ) as tb2) as tb3) as tb4
總結
以上是生活随笔為你收集整理的MSSQL的多层嵌套查询的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 作者:牛怡晗,女,就职于上海浦东发展银行
- 下一篇: 作者:梁永生(1971-),男,博士,深