SQL Server第四堂課 :視圖查詢方法,分頁查詢方法

來源:互聯網
上載者:User

標籤:

create view view_1        --建立一個新的視圖名as                         --建立視圖的函數select student.sno,sname,cno,DEGREE from  student join score on student.sno=score.sno    goselect *from view_1 where sno=‘1‘select *from(select student.sno,sname,cno,DEGREE from  student join score on student.sno=score.sno) as table 2 where sno=‘101‘--用as定義成一個暫存資料表,然後從表中再查詢記結果。也是子查詢的一種,將子查詢查詢出的結果集,當做一個暫存資料表使用。--視圖只有查詢作用。當對子查詢中的結果進行反覆查詢的時候,可以減少寫代碼的工作量 --分頁查詢,查詢一個表中第幾條和第幾條的資訊 select*from student  select top 2* from student where sno not in(select top 3 sno from student) --後面not in是屏蔽掉當前頁的前面頁的內容,前面top是取屏蔽之後的資料的一頁顯示條數 --兩行為一頁 --分頁的預存程序 create proc fenye  ----用函數來查詢分頁。查詢一個表中第幾條和第幾條的資訊 @nowye int, --當前頁 @number int --顯示行數 as           select top (@number) *from dingdanbiao where sno not in(select top((@nowye -1)*@number) sno from student ) go exec fenye 2, 3

 

SQL Server第四堂課 :視圖查詢方法,分頁查詢方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.